Order of tables in cross join

Hi,
I have queried the cross join of 2 select statements:
select * from (select statement 1 .......) t1
cross join
(select statement 2 ....) t2
I get different results when I’m changing the order of the tables in the cross join statement:
select * from (select statement 2 .......) t2
cross join
(select statement 1 ....) t1
How could it be?
Aviad

Hi, thank u for your patience.
CREATE TABLE "AVIAD"."LapTopSales" ("Customer " NVARCHAR2(50),
"ID" NVARCHAR2(50), "Price" FLOAT(126), "Product"
NVARCHAR2(50), "Purchase date" DATE, "Store City"
NVARCHAR2(50), "Store Price" FLOAT(126))
insert into "AVIAD"."LapTopSales" values ('L','P0',7555,'Dell P600','2007-04-23 00:00:00','Herzliya',7000);
insert into "AVIAD"."LapTopSales" values ('XKQF','P1',7834,'Toshiba P200-140','2007-04-23 00:00:00','Tel Aviv',6500);
insert into "AVIAD"."LapTopSales" values ('NXPD','P2',5631,'HP NX530','2007-04-23 00:00:00','Tel Aviv',4600);
insert into "AVIAD"."LapTopSales" values ('TPPFD','P3',7555,'Acer 3600','2007-04-23 00:00:00','Haifa',7000);
insert into "AVIAD"."LapTopSales" values ('GYT','P4',7555,'Acer 3600','2007-04-23 00:00:00','Jerusalem',7000);
insert into "AVIAD"."LapTopSales" values ('T','P5',5631,'HP NX530','2007-04-23 00:00:00','Jerusalem',4600);
insert into "AVIAD"."LapTopSales" values ('JCHD','P6',3212,'Acer 2400','2007-04-23 00:00:00','Herzliya',2700);
insert into "AVIAD"."LapTopSales" values ('FMYYY','P7',4821,'Dell P500','2007-04-23 00:00:00','Jerusalem',4100);
insert into "AVIAD"."LapTopSales" values ('AA','P8',8260,'Toshiba L30-10X','2007-04-23 00:00:00','Jerusalem',7102);
insert into "AVIAD"."LapTopSales" values ('XMPQP','P9',4821,'Dell P500','2007-04-23 00:00:00','Tel Aviv',4100);
insert into "AVIAD"."LapTopSales" values ('NL','P10',7900,'Acer 3800','2007-04-23 00:00:00','Tel Aviv',7200);
insert into "AVIAD"."LapTopSales" values ('AXP','P11',9225,'Sony V4-6X','2007-04-23 00:00:00','Jerusalem',8000);
insert into "AVIAD"."LapTopSales" values ('RDUJ','P12',7900,'Acer 3800','2007-04-23 00:00:00','Herzliya',7200);
insert into "AVIAD"."LapTopSales" values ('VHA','P13',4821,'Dell P500','2007-04-23 00:00:00','Tel Aviv',4100);
insert into "AVIAD"."LapTopSales" values ('WOR','P14',3512,'Dell P400','2007-04-23 00:00:00','Jerusalem',3000);
insert into "AVIAD"."LapTopSales" values ('DDVU','P15',3212,'Acer 2400','2007-04-23 00:00:00','Tel Aviv',2700);
insert into "AVIAD"."LapTopSales" values ('OE','P16',3821,'Acer 2500','2007-04-24 00:00:00','Tel Aviv',2900);
insert into "AVIAD"."LapTopSales" values ('NS','P17',9225,'Sony V4-6X','2007-04-24 00:00:00','Haifa',8000);
insert into "AVIAD"."LapTopSales" values ('DJ','P18',3961,'HP NX7300','2007-04-24 00:00:00','Natanya',3000);
insert into "AVIAD"."LapTopSales" values ('CXQ','P19',7555,'Acer 3600','2007-04-24 00:00:00','Natanya',7000);
insert into "AVIAD"."LapTopSales" values ('FG','P20',7412,'Sony V1-2X','2007-04-24 00:00:00','Tel Aviv',6300);
insert into "AVIAD"."LapTopSales" values ('TVE','P21',4821,'Dell P500','2007-04-24 00:00:00','Jerusalem',4100);
insert into "AVIAD"."LapTopSales" values ('VERW','P22',3733,'Toshiba L40-13G','2007-04-24 00:00:00','Jerusalem',3000);
insert into "AVIAD"."LapTopSales" values ('PA','P23',3212,'Acer 2400','2007-04-24 00:00:00','Tel Aviv',2700);
insert into "AVIAD"."LapTopSales" values ('WDJPQ','P24',4821,'Dell P500','2007-04-24 00:00:00','Natanya',4100);
insert into "AVIAD"."LapTopSales" values ('IKNE','P25',7412,'Sony V1-2X','2007-04-24 00:00:00','Herzliya',6300);
insert into "AVIAD"."LapTopSales" values ('LF','P26',3733,'Toshiba L40-13G','2007-04-24 00:00:00','Haifa',3000);
insert into "AVIAD"."LapTopSales" values ('J','P27',3212,'Acer 2400','2007-04-24 00:00:00','Natanya',2700);
insert into "AVIAD"."LapTopSales" values ('CW','P28',8260,'Toshiba L30-10X','2007-04-24 00:00:00','Jerusalem',7102);
insert into "AVIAD"."LapTopSales" values ('JLHJ','P29',4821,'Dell P500','2007-04-24 00:00:00','Natanya',4100);
insert into "AVIAD"."LapTopSales" values ('RE','P30',4821,'Dell P500','2007-04-24 00:00:00','Jerusalem',4100);
insert into "AVIAD"."LapTopSales" values ('KMI','P31',8331,'Sony V1-4X','2007-04-24 00:00:00','Tel Aviv',7100);
insert into "AVIAD"."LapTopSales" values ('D','P32',7555,'Acer 3600','2007-04-24 00:00:00','Herzliya',7000);
insert into "AVIAD"."LapTopSales" values ('EL','P33',8331,'Sony V1-4X','2007-04-24 00:00:00','Natanya',7100);
insert into "AVIAD"."LapTopSales" values ('SI','P34',7100,'HP NX800','2007-04-24 00:00:00','Tel Aviv',6400);
insert into "AVIAD"."LapTopSales" values ('NWVVO','P35',7834,'Toshiba P200-140','2007-04-24 00:00:00','Tel Aviv',6500);
insert into "AVIAD"."LapTopSales" values ('RJT','P36',8331,'Sony V1-4X','2007-04-24 00:00:00','Herzliya',7100);
insert into "AVIAD"."LapTopSales" values ('MTMY','P37',7900,'Acer 3800','2007-04-24 00:00:00','Jerusalem',7200);
insert into "AVIAD"."LapTopSales" values ('LOTD','P38',3212,'Acer 2400','2007-04-24 00:00:00','Herzliya',2700);
insert into "AVIAD"."LapTopSales" values ('LIXWF','P39',3733,'Toshiba L40-13G','2007-04-24 00:00:00','Natanya',3000);
insert into "AVIAD"."LapTopSales" values ('F','P40',7100,'HP NX800','2007-04-24 00:00:00','Natanya',6400);
insert into "AVIAD"."LapTopSales" values ('B','P41',4821,'Dell P500','2007-04-24 00:00:00','Natanya',4100);
insert into "AVIAD"."LapTopSales" values ('ALT','P42',3212,'Acer 2400','2007-04-24 00:00:00','Herzliya',2700);
insert into "AVIAD"."LapTopSales" values ('CMPLT','P43',3821,'Acer 2500','2007-04-24 00:00:00','Jerusalem',2900);
insert into "AVIAD"."LapTopSales" values ('YUPP','P44',3961,'HP NX7300','2007-04-24 00:00:00','Tel Aviv',3000);
insert into "AVIAD"."LapTopSales" values ('NQEQR','P45',3733,'Toshiba L40-13G','2007-04-24 00:00:00','Tel Aviv',3000);
insert into "AVIAD"."LapTopSales" values ('OPKNF','P46',3821,'Acer 2500','2007-04-24 00:00:00','Herzliya',2900);
insert into "AVIAD"."LapTopSales" values ('XQOGN','P47',3212,'Acer 2400','2007-04-24 00:00:00','Tel Aviv',2700);
insert into "AVIAD"."LapTopSales" values ('ET','P48',3733,'Toshiba L40-13G','2007-04-24 00:00:00','Tel Aviv',3000);
insert into "AVIAD"."LapTopSales" values ('A','P49',3212,'Acer 2400','2007-04-24 00:00:00','Natanya',2700);
insert into "AVIAD"."LapTopSales" values ('VEVD','P50',3733,'Toshiba L40-13G','2007-04-24 00:00:00','Haifa',3000);
insert into "AVIAD"."LapTopSales" values ('JXPRH','P51',3733,'Toshiba L40-13G','2007-04-24 00:00:00','Haifa',3000);
insert into "AVIAD"."LapTopSales" values ('QJBMI','P52',9225,'Sony V4-6X','2007-04-24 00:00:00','Natanya',8000);
insert into "AVIAD"."LapTopSales" values ('LVJJ','P53',3512,'Dell P400','2007-04-24 00:00:00','Jerusalem',3000);
insert into "AVIAD"."LapTopSales" values ('NQUEL','P54',3212,'Acer 2400','2007-04-24 00:00:00','Haifa',2700);
insert into "AVIAD"."LapTopSales" values ('MKV','P55',3212,'Acer 2400','2007-04-24 00:00:00','Herzliya',2700);
insert into "AVIAD"."LapTopSales" values ('NAHMV','P56',3733,'Toshiba L40-13G','2007-04-24 00:00:00','Natanya',3000);
insert into "AVIAD"."LapTopSales" values ('OFLW','P57',3733,'Toshiba L40-13G','2007-04-24 00:00:00','Jerusalem',3000);
insert into "AVIAD"."LapTopSales" values ('QYA','P58',9812,'HP NX7900','2007-04-24 00:00:00','Natanya',7412);
insert into "AVIAD"."LapTopSales" values ('FA','P59',3821,'Acer 2500','2007-04-24 00:00:00','Tel Aviv',2900);
insert into "AVIAD"."LapTopSales" values ('LIEQG','P60',5631,'HP NX530','2007-04-24 00:00:00','Jerusalem',4600);
insert into "AVIAD"."LapTopSales" values ('PEIUW','P61',9912,'Toshiba T50-300','2007-04-24 00:00:00','Tel Aviv',8412);
insert into "AVIAD"."LapTopSales" values ('DHK','P62',4821,'Dell P500','2007-04-24 00:00:00','Jerusalem',4100);
insert into "AVIAD"."LapTopSales" values ('C','P63',8331,'Sony V1-4X','2007-04-24 00:00:00','Natanya',7100);
insert into "AVIAD"."LapTopSales" values ('SA','P64',9812,'HP NX7900','2007-04-24 00:00:00','Tel Aviv',7412);
insert into "AVIAD"."LapTopSales" values ('YVQ','P65',5631,'HP NX530','2007-04-24 00:00:00','Haifa',4600);
insert into "AVIAD"."LapTopSales" values ('MKVRT','P66',5631,'HP NX530','2007-04-24 00:00:00','Haifa',4600);
insert into "AVIAD"."LapTopSales" values ('GLMXN','P67',3212,'Acer 2400','2007-04-24 00:00:00','Haifa',2700);
insert into "AVIAD"."LapTopSales" values ('WTIV','P68',9812,'HP NX7900','2007-04-24 00:00:00','Jerusalem',7412);
insert into "AVIAD"."LapTopSales" values ('JTIY','P69',3961,'HP NX7300','2007-04-24 00:00:00','Herzliya',3000);
insert into "AVIAD"."LapTopSales" values ('FGYW','P70',5631,'HP NX530','2007-04-24 00:00:00','Natanya',4600);
insert into "AVIAD"."LapTopSales" values ('LYMML','P71',3821,'Acer 2500','2007-04-24 00:00:00','Natanya',2900);
insert into "AVIAD"."LapTopSales" values ('SSO','P72',3821,'Acer 2500','2007-04-24 00:00:00','Natanya',2900);
insert into "AVIAD"."LapTopSales" values ('MNVQ','P73',9812,'HP NX7900','2007-04-24 00:00:00','Jerusalem',7412);
insert into "AVIAD"."LapTopSales" values ('P','P74',4821,'Dell P500','2007-04-24 00:00:00','Haifa',4100);
insert into "AVIAD"."LapTopSales" values ('WG','P75',8260,'Toshiba L30-10X','2007-04-24 00:00:00','Herzliya',7102);
insert into "AVIAD"."LapTopSales" values ('OK','P76',7900,'Acer 3800','2007-04-24 00:00:00','Tel Aviv',7200);
insert into "AVIAD"."LapTopSales" values ('V','P77',9812,'HP NX7900','2007-04-24 00:00:00','Haifa',7412);
insert into "AVIAD"."LapTopSales" values ('CIW','P78',7900,'Acer 3800','2007-04-24 00:00:00','Haifa',7200);
insert into "AVIAD"."LapTopSales" values ('EPSW','P79',3512,'Dell P400','2007-04-24 00:00:00','Tel Aviv',3000);
insert into "AVIAD"."LapTopSales" values ('T','P80',8260,'Toshiba L30-10X','2007-04-24 00:00:00','Haifa',7102);
insert into "AVIAD"."LapTopSales" values ('ALB','P81',8331,'Sony V1-4X','2007-04-24 00:00:00','Herzliya',7100);
insert into "AVIAD"."LapTopSales" values ('DA','P82',9225,'Sony V4-6X','2007-04-24 00:00:00','Haifa',8000);
insert into "AVIAD"."LapTopSales" values ('BDUX','P83',3733,'Toshiba L40-13G','2007-04-24 00:00:00','Natanya',3000);
insert into "AVIAD"."LapTopSales" values ('YCWI','P84',3733,'Toshiba L40-13G','2007-04-24 00:00:00','Natanya',3000);
insert into "AVIAD"."LapTopSales" values ('RHBT','P85',5631,'HP NX530','2007-04-24 00:00:00','Jerusalem',4600);
insert into "AVIAD"."LapTopSales" values ('WJFV','P86',5631,'HP NX530','2007-04-24 00:00:00','Jerusalem',4600);
insert into "AVIAD"."LapTopSales" values ('J','P87',7555,'Dell P600','2007-04-24 00:00:00','Jerusalem',7000);
insert into "AVIAD"."LapTopSales" values ('T','P88',5631,'HP NX530','2007-04-24 00:00:00','Natanya',4600);
insert into "AVIAD"."LapTopSales" values ('SVNP','P89',3212,'Acer 2400','2007-04-24 00:00:00','Herzliya',2700);
insert into "AVIAD"."LapTopSales" values ('UBBNQ','P90',3961,'HP NX7300','2007-04-24 00:00:00','Jerusalem',3000);
insert into "AVIAD"."LapTopSales" values ('R','P91',9812,'HP NX7900','2007-04-24 00:00:00','Jerusalem',7412);
insert into "AVIAD"."LapTopSales" values ('DQWP','P92',7100,'HP NX800','2007-04-24 00:00:00','Tel Aviv',6400);
insert into "AVIAD"."LapTopSales" values ('GA','P93',3212,'Acer 2400','2007-04-24 00:00:00','Natanya',2700);
insert into "AVIAD"."LapTopSales" values ('T','P94',4821,'Dell P500','2007-04-24 00:00:00','Herzliya',4100);
insert into "AVIAD"."LapTopSales" values ('RIOR','P95',3961,'HP NX7300','2007-04-24 00:00:00','Haifa',3000);
insert into "AVIAD"."LapTopSales" values ('H','P96',3212,'Acer 2400','2007-04-24 00:00:00','Herzliya',2700);
insert into "AVIAD"."LapTopSales" values ('JWIEE','P97',8260,'Toshiba L30-10X','2007-04-24 00:00:00','Tel Aviv',7102);
insert into "AVIAD"."LapTopSales" values ('LMANP','P98',9341,'Sony V4-8X','2007-04-24 00:00:00','Natanya',8200);
insert into "AVIAD"."LapTopSales" values ('SJQX','P99',3512,'Dell P400','2007-04-24 00:00:00','Tel Aviv',3000);
insert into "AVIAD"."LapTopSales" values ('F','P100',7555,'Dell P600','2007-04-24 00:00:00','Haifa',7000);
insert into "AVIAD"."LapTopSales" values ('XJB','P101',7555,'Acer 3600','2007-04-24 00:00:00','Natanya',7000);
insert into "AVIAD"."LapTopSales" values ('SLXCU','P102',3821,'Acer 2500','2007-04-24 00:00:00','Tel Aviv',2900);
insert into "AVIAD"."LapTopSales" values ('HD','P103',3821,'Acer 2500','2007-04-24 00:00:00','Herzliya',2900);
insert into "AVIAD"."LapTopSales" values ('T','P104',9341,'Sony V4-8X','2007-04-24 00:00:00','Jerusalem',8200);
insert into "AVIAD"."LapTopSales" values ('GFI','P105',7412,'Sony V1-2X','2007-04-24 00:00:00','Herzliya',6300);
insert into "AVIAD"."LapTopSales" values ('YUL','P106',3961,'HP NX7300','2007-04-24 00:00:00','Herzliya',3000);
insert into "AVIAD"."LapTopSales" values ('H','P107',3961,'HP NX7300','2007-04-24 00:00:00','Natanya',3000);
insert into "AVIAD"."LapTopSales" values ('JNBJ','P108',3821,'Acer 2500','2007-04-24 00:00:00','Herzliya',2900);
insert into "AVIAD"."LapTopSales" values ('J','P109',9812,'HP NX7900','2007-04-24 00:00:00','Tel Aviv',7412);
insert into "AVIAD"."LapTopSales" values ('LLJ','P110',9341,'Sony V4-8X','2007-04-24 00:00:00','Natanya',8200);
insert into "AVIAD"."LapTopSales" values ('HAPR','P111',7412,'Sony V1-2X','2007-04-24 00:00:00','Tel Aviv',6300);
insert into "AVIAD"."LapTopSales" values ('SP','P112',7412,'Sony V1-2X','2007-04-24 00:00:00','Herzliya',6300);
insert into "AVIAD"."LapTopSales" values ('S','P113',9812,'HP NX7900','2007-04-24 00:00:00','Tel Aviv',7412);
insert into "AVIAD"."LapTopSales" values ('OVE','P114',9912,'Toshiba T50-300','2007-04-24 00:00:00','Tel Aviv',8412);
insert into "AVIAD"."LapTopSales" values ('L','P115',9812,'HP NX7900','2007-04-24 00:00:00','Haifa',7412);
insert into "AVIAD"."LapTopSales" values ('OGSL','P116',3821,'Acer 2500','2007-04-24 00:00:00','Tel Aviv',2900);
insert into "AVIAD"."LapTopSales" values ('TE','P117',7100,'HP NX800','2007-04-24 00:00:00','Natanya',6400);
insert into "AVIAD"."LapTopSales" values ('XW','P118',3961,'HP NX7300','2007-04-24 00:00:00','Haifa',3000);
insert into "AVIAD"."LapTopSales" values ('TWVR','P119',3821,'Acer 2500','2007-04-25 00:00:00','Natanya',2900);

Similar Messages

  • Cross Join in SQL

    From relational algebra, cross join or cross product or cartesion product is the set of all combinations of tuples in R and S where R and S are relations. Is there anyway I can do the same in SQL?
    Thanks,
    Mustafa

    in oracle 9i u can also say
    select <column list>
    from <table 1> cross join <table 2>
    where <condition>
    here where clause is optional....

  • INVENTORY & ORDER MANAGEMENT Tables join conditions required

    Hi All,
    I have to create one view, it has to display item_number, item_description,quantity_in_warehouse and pendingquantity_in_salesorder.
    query is based on INVENTORY & ORDER MANAGEMENT Tables. i have written below query, it is not giving expected output. Kindly go through once and rectify me if i did any thing wrong while writing the join conditions.
    SELECT mtlb.segment1 Item_Number,
    mtlb.description Item_Description,
    mtld.transaction_quantity Quantity_in_Wearhouse,
    oel.ordered_quantity PendingQuantity_in_SalesOrder
    FROM mtl_system_items_b mtlb,
    mtl_onhand_quantities_detail mtld,
    oe_order_headers_all oeh,
    oe_order_lines_all oel
    WHERE mtlb.inventory_item_id = mtld.inventory_item_id
    AND mtlb.organization_id ; = mtld.organization_id
    AND mtlb.inventory_item_id ; = oel.inventory_item_id
    AND oeh.header_id ; = oel.header_id
    AND oeh.org_id ; = oel.org_id
    AND oeh.ship_from_org_id ; = mtlb.organization_id
    AND oel.ship_from_org_id ; = mtlb.organization_id
    AND mtld.subinventory_code LIKE 'Warehouse'
    AND oel.flow_status_code LIKE 'AWAITING_SHIPPING'
    ORDER BY mtlb.segment1;
    it is bit urgent. please help me to resolve this issue.
    Thanks.
    Edited by: user627525 on Jul 19, 2010 4:35 AM

    Hi Jonny,
    Thanks for your reply. it is very useful for me. need small clarification.
    i have execute the query that u have given. please find the following output.
    segment1 order_number line_number shipment_number on_hand
    210020004000011 10005 1 1 139150
    210020004000011 10006 1 1 139150
    210020004000013 10005 2 1 27675
    210020004000013 10006 2 1 27675
    i have modified the query and added column ordered_quantity from oe_order_lines_all table.
    SELECT
    mtlb.segment1 ; as Item_Number,
    mtlb.description as Item_Description,
    sum(mtld.primary_transaction_quantity) as Quantity_in_Whouse,
    oel.ordered_quantity as PQuantity_in_SOrder
    FROM oe_order_headers_all oeh,
    oe_order_lines_all oel,
    mtl_system_items_b mtlb,
    mtl_onhand_quantities_detail mtld
    WHERE oel.header_id = oeh.header_id
    AND oel.inventory_item_id = mtlb.inventory_item_id
    AND oel.ship_from_org_id = mtlb.organization_id
    AND oel.inventory_item_id = mtld.inventory_item_id
    AND oel.ship_from_org_id = mtld.organization_id
    AND oel.flow_status_code = 'AWAITING_SHIPPING'
    AND mtld.subinventory_code = 'Warehouse'
    GROUP By mtlb.segment1,mtlb.description,oel.ordered_quantity
    ORDER BY mtlb.segment1;
    i have executed the above query. Quantity_in_Whouse is showing double the actual available quantity.
    item_number item_description Quantity_in_Whouse PQuantity_in_SOrder
    210020004000011 item1 278300 100
    210020004000013 item3 55350 125
    when i executed the below query, Quantity_in_Whouse is showing 139050 and 27550 respectively.
    SELECT mtlb.segment1 Item_Number,
    mtlb.description,
    sum(mtld.primary_transaction_quantity) Quantity_in_Whouse
    FROM mtl_system_items_b mtlb,
    mtl_onhand_quantities_detail mtld
    WHERE mtlb.inventory_item_id = mtld.inventory_item_id
    AND mtlb.organization_id ; = mtld.organization_id
    AND mtld.subinventory_code LIKE 'Warehouse'
    and mtlb.segment1 in ('210020004000011','210020004000013')
    group by mtlb.segment1, mtlb.description
    ORDER BY mtlb.segment1;
    item_number item_description Quantity_in_Whouse
    210020004000011 item1 139050
    210020004000013 item3 27550
    please give some solution so that i can display Quantity_in_Whouse as 139050 and 27550 .
    if i am any thing wrong please rectify me.
    Thanks in advance.
    Edited by: user627525 on Jul 19, 2010 7:54 AM
    Edited by: user627525 on Jul 19, 2010 7:56 AM
    Edited by: user627525 on Jul 19, 2010 9:39 AM

  • Tables of View Joined in Wrong Order When View Joined to Other Tables

    I have the following view:
    select
         distinct
         'PKG' item_type_code,
         msibk.organization_id,
         msibk.inventory_item_id
    from
         mtl_system_items_b_kfv msibk,
         mtl_item_categories mic,
         mtl_default_category_sets mdcs,
         mtl_categories_b_kfv mcbk
    where
         msibk.organization_id = mic.organization_id
         and msibk.inventory_item_id = mic.inventory_item_id
         and mic.category_set_id = mdcs.category_set_id
         --1 Inventory (Lookup = MTL_FUNCTIONAL_AREAS)
         and mdcs.functional_area_id = 1
         and mic.category_id = mcbk.category_id
         and mcbk.segment1 = 'EXP'
         and mcbk.segment2 in ( 'PACKAGING' )When I access the columns like this:
    select
    from
         xxcus_mtl_sys_item_types_v
    where
         organization_id = :1
         and inventory_item_id = :2
         and item_type_code = :3It correctly accesses MTL_SYSTEM_ITEMS_B second in the explain plan and everything is good.
    But when it is part of a join, it accesses MTL_SYSTEM_ITEMS_B last in the explain plan and has performance issues.
    select
         msi.segment1
    from
         xxcus_mtl_sys_item_types_v x,
         mtl_system_items msi
    where
         msi.organization_id = x.organization_id
         and msi.inventory_item_id = x.inventory_item_id
         and x.item_type_code = 'PAK'Any ideas why the view tables are getting joined incorrectly when the view is joined with another table?
    Thanks,
    Kurz

    The query I posted for the view is just an excerpt. It is several nearly identical queries with UNION ALL between them. I get the same results when I have only one query in the view.
    Here is the explain plan for the first query:
    | Id  | Operation                          | Name                         | Rows  | Bytes | Cost (%CPU)|
    |   0 | SELECT STATEMENT                   |                              |     5 |   160 |    25  (20)|
    |   1 |  VIEW                              | XXCUS_MTL_SYS_ITEM_TYPES_V   |     5 |   160 |    25  (20)|
    |   2 |   UNION-ALL                        |                              |       |       |            |
    |   3 |    SORT UNIQUE NOSORT              |                              |     1 |    71 |     5  (20)|
    |*  4 |     FILTER                         |                              |       |       |            |
    |   5 |      NESTED LOOPS                  |                              |     1 |    71 |     4   (0)|
    |   6 |       NESTED LOOPS                 |                              |     1 |    36 |     3   (0)|
    |   7 |        NESTED LOOPS                |                              |     1 |    17 |     1   (0)|
    |   8 |         TABLE ACCESS BY INDEX ROWID| MTL_DEFAULT_CATEGORY_SETS    |     1 |     8 |     1   (0)|
    |*  9 |          INDEX UNIQUE SCAN         | MTL_DEFAULT_CATEGORY_SETS_U1 |     1 |       |     0   (0)|
    |* 10 |         INDEX UNIQUE SCAN          | MTL_SYSTEM_ITEMS_B_U1        |     1 |     9 |     0   (0)|
    |* 11 |        INDEX RANGE SCAN            | MTL_ITEM_CATEGORIES_U1       |     1 |    19 |     2   (0)|
    |* 12 |       TABLE ACCESS BY INDEX ROWID  | MTL_CATEGORIES_B             |     1 |    35 |     1   (0)|
    |* 13 |        INDEX UNIQUE SCAN           | MTL_CATEGORIES_B_U1          |     1 |       |     0   (0)|
    |  14 |    SORT UNIQUE NOSORT              |                              |     1 |    63 |     5  (20)|
    |* 15 |     FILTER                         |                              |       |       |            |
    |  16 |      NESTED LOOPS                  |                              |     1 |    63 |     4   (0)|
    |  17 |       NESTED LOOPS                 |                              |     1 |    36 |     3   (0)|
    |  18 |        NESTED LOOPS                |                              |     1 |    17 |     1   (0)|
    |  19 |         TABLE ACCESS BY INDEX ROWID| MTL_DEFAULT_CATEGORY_SETS    |     1 |     8 |     1   (0)|
    |* 20 |          INDEX UNIQUE SCAN         | MTL_DEFAULT_CATEGORY_SETS_U1 |     1 |       |     0   (0)|
    |* 21 |         INDEX UNIQUE SCAN          | MTL_SYSTEM_ITEMS_B_U1        |     1 |     9 |     0   (0)|
    |* 22 |        INDEX RANGE SCAN            | MTL_ITEM_CATEGORIES_U1       |     1 |    19 |     2   (0)|
    |* 23 |       TABLE ACCESS BY INDEX ROWID  | MTL_CATEGORIES_B             |     1 |    27 |     1   (0)|
    |* 24 |        INDEX UNIQUE SCAN           | MTL_CATEGORIES_B_U1          |     1 |       |     0   (0)|
    |  25 |    SORT UNIQUE NOSORT              |                              |     1 |    71 |     5  (20)|
    |* 26 |     FILTER                         |                              |       |       |            |
    |  27 |      NESTED LOOPS                  |                              |     1 |    71 |     4   (0)|
    |  28 |       NESTED LOOPS                 |                              |     1 |    36 |     3   (0)|
    |  29 |        NESTED LOOPS                |                              |     1 |    17 |     1   (0)|
    |  30 |         TABLE ACCESS BY INDEX ROWID| MTL_DEFAULT_CATEGORY_SETS    |     1 |     8 |     1   (0)|
    |* 31 |          INDEX UNIQUE SCAN         | MTL_DEFAULT_CATEGORY_SETS_U1 |     1 |       |     0   (0)|
    |* 32 |         INDEX UNIQUE SCAN          | MTL_SYSTEM_ITEMS_B_U1        |     1 |     9 |     0   (0)|
    |* 33 |        INDEX RANGE SCAN            | MTL_ITEM_CATEGORIES_U1       |     1 |    19 |     2   (0)|
    |* 34 |       TABLE ACCESS BY INDEX ROWID  | MTL_CATEGORIES_B             |     1 |    35 |     1   (0)|
    |* 35 |        INDEX UNIQUE SCAN           | MTL_CATEGORIES_B_U1          |     1 |       |     0   (0)|
    |  36 |    SORT UNIQUE NOSORT              |                              |     1 |    71 |     5  (20)|
    |* 37 |     FILTER                         |                              |       |       |            |
    |  38 |      NESTED LOOPS                  |                              |     1 |    71 |     4   (0)|
    |  39 |       NESTED LOOPS                 |                              |     1 |    36 |     3   (0)|
    |  40 |        NESTED LOOPS                |                              |     1 |    17 |     1   (0)|
    |  41 |         TABLE ACCESS BY INDEX ROWID| MTL_DEFAULT_CATEGORY_SETS    |     1 |     8 |     1   (0)|
    |* 42 |          INDEX UNIQUE SCAN         | MTL_DEFAULT_CATEGORY_SETS_U1 |     1 |       |     0   (0)|
    |* 43 |         INDEX UNIQUE SCAN          | MTL_SYSTEM_ITEMS_B_U1        |     1 |     9 |     0   (0)|
    |* 44 |        INDEX RANGE SCAN            | MTL_ITEM_CATEGORIES_U1       |     1 |    19 |     2   (0)|
    |* 45 |       TABLE ACCESS BY INDEX ROWID  | MTL_CATEGORIES_B             |     1 |    35 |     1   (0)|
    |* 46 |        INDEX UNIQUE SCAN           | MTL_CATEGORIES_B_U1          |     1 |       |     0   (0)|
    |  47 |    SORT UNIQUE NOSORT              |                              |     1 |    71 |     5  (20)|
    |* 48 |     FILTER                         |                              |       |       |            |
    |  49 |      NESTED LOOPS                  |                              |     1 |    71 |     4   (0)|
    |  50 |       NESTED LOOPS                 |                              |     1 |    36 |     3   (0)|
    |  51 |        NESTED LOOPS                |                              |     1 |    17 |     1   (0)|
    |  52 |         TABLE ACCESS BY INDEX ROWID| MTL_DEFAULT_CATEGORY_SETS    |     1 |     8 |     1   (0)|
    |* 53 |          INDEX UNIQUE SCAN         | MTL_DEFAULT_CATEGORY_SETS_U1 |     1 |       |     0   (0)|
    |* 54 |         INDEX UNIQUE SCAN          | MTL_SYSTEM_ITEMS_B_U1        |     1 |     9 |     0   (0)|
    |* 55 |        INDEX RANGE SCAN            | MTL_ITEM_CATEGORIES_U1       |     1 |    19 |     2   (0)|
    |* 56 |       TABLE ACCESS BY INDEX ROWID  | MTL_CATEGORIES_B             |     1 |    35 |     1   (0)|
    |* 57 |        INDEX UNIQUE SCAN           | MTL_CATEGORIES_B_U1          |     1 |       |     0   (0)|
    --------------------------------------------------------------------------------------------------------Here is the explain plan for the second query:
    | Id  | Operation                           | Name                         | Rows  | Bytes | Cost (%CPU)|
    |   0 | SELECT STATEMENT                    |                              |     5 |   240 |    10  (50)|
    |   1 |  NESTED LOOPS                       |                              |     5 |   240 |    10  (50)|
    |   2 |   VIEW                              | XXCUS_MTL_SYS_ITEM_TYPES_V   |     5 |   160 |     5 (100)|
    |   3 |    UNION-ALL                        |                              |       |       |            |
    |   4 |     HASH UNIQUE                     |                              |     1 |    71 |     1 (100)|
    |*  5 |      FILTER                         |                              |       |       |            |
    |   6 |       NESTED LOOPS                  |                              |    17 |  1207 |    77   (0)|
    |   7 |        NESTED LOOPS                 |                              |    16 |   992 |    77   (0)|
    |   8 |         NESTED LOOPS                |                              |     1 |    43 |     7   (0)|
    |   9 |          TABLE ACCESS BY INDEX ROWID| MTL_DEFAULT_CATEGORY_SETS    |     1 |     8 |     1   (0)|
    |* 10 |           INDEX UNIQUE SCAN         | MTL_DEFAULT_CATEGORY_SETS_U1 |     1 |       |     0   (0)|
    |* 11 |          TABLE ACCESS BY INDEX ROWID| MTL_CATEGORIES_B             |     1 |    35 |     6   (0)|
    |* 12 |           INDEX RANGE SCAN          | MTL_CATEGORIES_B_N1          |    44 |       |     2   (0)|
    |* 13 |         TABLE ACCESS BY INDEX ROWID | MTL_ITEM_CATEGORIES          |    49 |   931 |    70   (0)|
    |* 14 |          INDEX RANGE SCAN           | MTL_ITEM_CATEGORIES_N3       |   441 |       |     4   (0)|
    |* 15 |        INDEX UNIQUE SCAN            | MTL_SYSTEM_ITEMS_B_U1        |     1 |     9 |     0   (0)|
    |  16 |     HASH UNIQUE                     |                              |     1 |    63 |     1 (100)|
    |* 17 |      FILTER                         |                              |       |       |            |
    |  18 |       NESTED LOOPS                  |                              |  2158 |   132K|   250   (1)|
    |  19 |        NESTED LOOPS                 |                              |  2134 |   112K|   249   (0)|
    |  20 |         NESTED LOOPS                |                              |    44 |  1540 |     7   (0)|
    |  21 |          TABLE ACCESS BY INDEX ROWID| MTL_DEFAULT_CATEGORY_SETS    |     1 |     8 |     1   (0)|
    |* 22 |           INDEX UNIQUE SCAN         | MTL_DEFAULT_CATEGORY_SETS_U1 |     1 |       |     0   (0)|
    |  23 |          TABLE ACCESS BY INDEX ROWID| MTL_CATEGORIES_B             |    44 |  1188 |     6   (0)|
    |* 24 |           INDEX RANGE SCAN          | MTL_CATEGORIES_B_N1          |    44 |       |     2   (0)|
    |* 25 |         TABLE ACCESS BY INDEX ROWID | MTL_ITEM_CATEGORIES          |    49 |   931 |    70   (0)|
    |* 26 |          INDEX RANGE SCAN           | MTL_ITEM_CATEGORIES_N3       |   441 |       |     4   (0)|
    |* 27 |        INDEX UNIQUE SCAN            | MTL_SYSTEM_ITEMS_B_U1        |     1 |     9 |     0   (0)|
    |  28 |     HASH UNIQUE                     |                              |     1 |    71 |     1 (100)|
    |* 29 |      FILTER                         |                              |       |       |            |
    |  30 |       NESTED LOOPS                  |                              |    33 |  2343 |    77   (0)|
    |  31 |        NESTED LOOPS                 |                              |    33 |  2046 |    77   (0)|
    |  32 |         NESTED LOOPS                |                              |     1 |    43 |     7   (0)|
    |  33 |          TABLE ACCESS BY INDEX ROWID| MTL_DEFAULT_CATEGORY_SETS    |     1 |     8 |     1   (0)|
    |* 34 |           INDEX UNIQUE SCAN         | MTL_DEFAULT_CATEGORY_SETS_U1 |     1 |       |     0   (0)|
    |* 35 |          TABLE ACCESS BY INDEX ROWID| MTL_CATEGORIES_B             |     1 |    35 |     6   (0)|
    |* 36 |           INDEX RANGE SCAN          | MTL_CATEGORIES_B_N1          |    44 |       |     2   (0)|
    |* 37 |         TABLE ACCESS BY INDEX ROWID | MTL_ITEM_CATEGORIES          |    49 |   931 |    70   (0)|
    |* 38 |          INDEX RANGE SCAN           | MTL_ITEM_CATEGORIES_N3       |   441 |       |     4   (0)|
    |* 39 |        INDEX UNIQUE SCAN            | MTL_SYSTEM_ITEMS_B_U1        |     1 |     9 |     0   (0)|
    |  40 |     HASH UNIQUE                     |                              |     1 |    71 |     1 (100)|
    |* 41 |      FILTER                         |                              |       |       |            |
    |  42 |       NESTED LOOPS                  |                              |    17 |  1207 |    77   (0)|
    |  43 |        NESTED LOOPS                 |                              |    16 |   992 |    77   (0)|
    |  44 |         NESTED LOOPS                |                              |     1 |    43 |     7   (0)|
    |  45 |          TABLE ACCESS BY INDEX ROWID| MTL_DEFAULT_CATEGORY_SETS    |     1 |     8 |     1   (0)|
    |* 46 |           INDEX UNIQUE SCAN         | MTL_DEFAULT_CATEGORY_SETS_U1 |     1 |       |     0   (0)|
    |* 47 |          TABLE ACCESS BY INDEX ROWID| MTL_CATEGORIES_B             |     1 |    35 |     6   (0)|
    |* 48 |           INDEX RANGE SCAN          | MTL_CATEGORIES_B_N1          |    44 |       |     2   (0)|
    |* 49 |         TABLE ACCESS BY INDEX ROWID | MTL_ITEM_CATEGORIES          |    49 |   931 |    70   (0)|
    |* 50 |          INDEX RANGE SCAN           | MTL_ITEM_CATEGORIES_N3       |   441 |       |     4   (0)|
    |* 51 |        INDEX UNIQUE SCAN            | MTL_SYSTEM_ITEMS_B_U1        |     1 |     9 |     0   (0)|
    |  52 |     HASH UNIQUE                     |                              |     1 |    71 |     1 (100)|
    |* 53 |      FILTER                         |                              |       |       |            |
    |  54 |       NESTED LOOPS                  |                              |    17 |  1207 |    77   (0)|
    |  55 |        NESTED LOOPS                 |                              |    16 |   992 |    77   (0)|
    |  56 |         NESTED LOOPS                |                              |     1 |    43 |     7   (0)|
    |  57 |          TABLE ACCESS BY INDEX ROWID| MTL_DEFAULT_CATEGORY_SETS    |     1 |     8 |     1   (0)|
    |* 58 |           INDEX UNIQUE SCAN         | MTL_DEFAULT_CATEGORY_SETS_U1 |     1 |       |     0   (0)|
    |* 59 |          TABLE ACCESS BY INDEX ROWID| MTL_CATEGORIES_B             |     1 |    35 |     6   (0)|
    |* 60 |           INDEX RANGE SCAN          | MTL_CATEGORIES_B_N1          |    44 |       |     2   (0)|
    |* 61 |         TABLE ACCESS BY INDEX ROWID | MTL_ITEM_CATEGORIES          |    49 |   931 |    70   (0)|
    |* 62 |          INDEX RANGE SCAN           | MTL_ITEM_CATEGORIES_N3       |   441 |       |     4   (0)|
    |* 63 |        INDEX UNIQUE SCAN            | MTL_SYSTEM_ITEMS_B_U1        |     1 |     9 |     0   (0)|
    |  64 |   TABLE ACCESS BY INDEX ROWID       | MTL_SYSTEM_ITEMS_B           |     1 |    16 |     1   (0)|
    |* 65 |    INDEX UNIQUE SCAN                | MTL_SYSTEM_ITEMS_B_U1        |     1 |       |     0   (0)|
    ---------------------------------------------------------------------------------------------------------

  • [8i] Need help with full outer join combined with a cross-join....

    I can't figure out how to combine a full outer join with another type of join ... is this possible?
    Here's some create table and insert statements for some basic sample data:
    CREATE TABLE     my_tab1
    (     record_id     NUMBER     NOT NULL     
    ,     workstation     VARCHAR2(4)
    ,     my_value     NUMBER
         CONSTRAINT my_tab1_pk PRIMARY KEY (record_id)
    INSERT INTO     my_tab1
    VALUES(1,'ABCD',10);
    INSERT INTO     my_tab1
    VALUES(2,'ABCD',15);
    INSERT INTO     my_tab1
    VALUES(3,'ABCD',5);
    INSERT INTO     my_tab1
    VALUES(4,'A123',5);
    INSERT INTO     my_tab1
    VALUES(5,'A123',10);
    INSERT INTO     my_tab1
    VALUES(6,'A123',20);
    INSERT INTO     my_tab1
    VALUES(7,'????',5);
    CREATE TABLE     my_tab2
    (     workstation     VARCHAR2(4)
    ,     wkstn_name     VARCHAR2(20)
         CONSTRAINT my_tab2_pk PRIMARY KEY (workstation)
    INSERT INTO     my_tab2
    VALUES('ABCD','WKSTN 1');
    INSERT INTO     my_tab2
    VALUES('A123','WKSTN 2');
    INSERT INTO     my_tab2
    VALUES('B456','WKSTN 3');
    CREATE TABLE     my_tab3
    (     my_nbr1     NUMBER
    ,     my_nbr2     NUMBER
    INSERT INTO     my_tab3
    VALUES(1,2);
    INSERT INTO     my_tab3
    VALUES(2,3);
    INSERT INTO     my_tab3
    VALUES(3,4);And, the results I want to get:
    workstation     sum(my_value)     wkstn_name     my_nbr1     my_nbr2
    ABCD          30          WKSTN 1          1     2
    ABCD          30          WKSTN 1          2     3
    ABCD          30          WKSTN 1          3     4
    A123          35          WKSTN 2          1     2
    A123          35          WKSTN 2          2     3
    A123          35          WKSTN 2          3     4
    B456          0          WKSTN 3          1     2
    B456          0          WKSTN 3          2     3
    B456          0          WKSTN 3          3     4
    ????          5          NULL          1     2
    ????          5          NULL          2     3
    ????          5          NULL          3     4I've tried a number of different things, googled my problem, and no luck yet...
    SELECT     t1.workstation
    ,     SUM(t1.my_value)
    ,     t2.wkstn_name
    ,     t3.my_nbr1
    ,     t3.my_nbr2
    FROM     my_tab1 t1
    ,     my_tab2 t2
    ,     my_tab3 t3
    ...So, what I want is a full outer join of t1 and t2 on workstation, and a cross-join of that with t3. I'm wondering if I can't find any examples of this online because it's not possible....
    Note: I'm stuck dealing with Oracle 8i
    Thanks!!

    Hi,
    The query I posted yesterday is a little more complicated than it needs to be.
    Since my_tab2.workstation is unique, there's no reason to do a separate sub-query like mt1; we can join my_tab1 to my_tab2 and get the SUM all in one sub-query.
    SELECT       foj.workstation
    ,       foj.sum_my_value
    ,       foj.wkstn_name
    ,       mt3.my_nbr1
    ,       mt3.my_nbr2
    FROM       (     -- Begin in-line view foj for full outer join
              SELECT        mt1.workstation
              ,        SUM (mt1.my_value)     AS sum_my_value
              ,        mt2.wkstn_name
              FROM        my_tab1   mt1
              ,        my_tab2   mt2
              WHERE        mt1.workstation     = mt2.workstation (+)
              GROUP BY   mt1.workstation
              ,        mt2.wkstn_name
                    UNION ALL
              SELECT      workstation
              ,      0      AS sum_my_value
              ,      wkstn_name
              FROM      my_tab2
              WHERE      workstation     NOT IN (     -- Begin NOT IN sub-query
                                               SELECT      workstation
                                       FROM      my_tab1
                                       WHERE      workstation     IS NOT NULL
                                     )     -- End NOT IN sub-query
           ) foj     -- End in-line view foj for full outer join
    ,       my_tab3  mt3
    ORDER BY  foj.wkstn_name
    ,       foj.workstation
    ,       mt3.my_nbr1
    ,       mt3.my_nbr2
    ;Thanks for posting the CREATE TABLE and INSERT statements, as well as the very clear desired results!
    user11033437 wrote:
    ... So, what I want is a full outer join of t1 and t2 on workstation, and a cross-join of that with t3. That it, exactly!
    The tricky part is how and when to get SUM (my_value). You might approach this by figuring out exactly what my_tab3 has to be cross-joined to; that is, exactly what should the result set of the full outer join between my_tab1 and my_tab2 look like. To do that, take your desired results, remove the columns that do not come from the full outer join, and remove the duplicate rows. You'll get:
    workstation     sum(my_value)     wkstn_name
    ABCD          30          WKSTN 1          
    A123          35          WKSTN 2          
    B456          0          WKSTN 3          
    ????          5          NULL          So the core of the problem is how to get these results from my_tab1 and my_tab2, which is done in sub-query foj above.
    I tried to use self-documenting names in my code. I hope you can understand it.
    I could spend hours explaining different parts of this query in more detail, but I'm sure I'd waste some of that time explaining things you already understand. If you want an explanation of somthing(s) specific, let me know.

  • Illegal cross join within the same dimension caused by incorrect subject ar

    hi!
    Imagine the following BMM:
    There is one Logical Dimension Table "Service Account" with the following LTS:
    - LTS "D_SERVICE"
    - LTS "D_SERVICE_CLASS"
    - LTS "D_SERVICE_STATUS"
    This Logical Tabe "Service Account" joins (One-to-many) with several Fact Tables (other Logical Tables).
    In the Physical Layer the joins for the "Service Account" LTS are:
    - One-to-many between D_SERVICE_CLASS and D_SERVICE
    - One-to-many between D_SERVICE_STATUS and D_SERVICE
    The problem is that when I build a report in Answers using only the following columns of the Logical Table "Service Account":
    - Service Class Desc (which exists in the Logical Table "Service Account" and in the Physical Table D_SERVICE_CLASS)
    - Service Status Desc (which exists in the Logical Table "Service Account" and in the Physical Tabl D_SERVICE_STATUS)
    - MSISDN (which existis in the Logical Table "Service Account" and in the Phsyical Table D_SERVICE)
    the following error appears:
    Estado: HY000. Código: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 14065] Illegal cross join within the same dimension caused by incorrect subject area setup: [ (select * from prd.D_SERVICE where SOURCE_SYS in ('ARBOR','PPB') and DW_SERV_ST_ID in (100000003,100000009)) as T1836, D_SERVICE_CLASS T1916] with [ D_SERVICE_STATUS T1948] (HY000)
    SQL emitido: SELECT "SERVICE ACCOUNT"."TLC MSISDN9" saw_0, "SERVICE ACCOUNT"."IWS Service Class Desc" saw_1, "SERVICE ACCOUNT"."TLC Service Status Desc" saw_2 FROM "VFPT - Upgrade Siebel" WHERE "SERVICE ACCOUNT"."TLC MSISDN9" = '917330340' ORDER BY saw_0, saw_1, saw_2
    Help, please!
    Thanks.

    Physically, only D_SERVICE is joined to the facts. Then D_SERVICE_CLASS is joined to D_SERVICE (one-to-many) and D_SERVICE_STATUS is joined also to D_SERVICE (one-to-many).
    In the BMM, there is only one Logical Dimension Table for those 3 physical tables. This Logical Dimension Table is called "Service Account" and has 3 LTS: D_SERVICE, D_SERVICE_CLASS, D_SERVICE_STATUS. The Logical Dimension Table has several logical columns that are associated to those 3 LTS: SERVICE_KEY, SERVICE_CLASS_KEY, SERVICE_STATUS_KEY, SERVICE_MSISDN, SERVICE_CLASS_DESC, SERVICE_STATUS_DESC.
    The Logical Dimension Table "Service Account" is then joined to a fact table (one-to-many).
    I didn't understand the suggestion about the 3 LTS... Aren't we doing that already? Can you explain it better, please?
    thanks.

  • How to resolve illegal cross join error

    Can someone please tell me how can we avoid illegal cross join error in modeling? If someone has any reference document , please share it.
    I have 5 tables - Dim (A, B , C,E) and Fact( D). C is lookup table which is used to resolve the lookup code column in table E.
    The relationships between these are
    A--< B--< E >--C
    & A--<D
    My requirement is i have to expose Attributes of A,B ,C & E within Dimension.
    These attributes (from B,C,E) will be treated as property of A.
    Someone may query these attributes without selecting any column from fact table.
    Thanks & Regards,
    Ashish

    Hi Ashish,
    it's not the first time you come up with this kind of question and I'm wondering if you understand the principle of granularity when I read your questions.
    On physical level, a fact table must always join with the lowest level of detail of your dimension table. Let me explain, by giving an example which looks like your situation.
    Assume I have three tables:
    Table "E" contains products, which has attributes like: product_id and product_name
    Table "B" contains order line items, which has attributes like: order_line_item_id, order_id and product_id.
    Table "A" contains orders, which has attributes like: order_id and customer_name.
    Table "D" contains facts ("metrical data") about my order: which has attributes like: order_id, order_revenue.
    This will be the diagram on physical level: E--<B--<A--<D
    Here are my joins: E.product_id on B.produc_id, B.order_id on A.order_id, A.order_id--<D.order_id
    Now, my question to you is: will I be able to get the revenue of a certain product?
    The answer is: No, because I don't know what part of my order is spent on a certain product. The problem is thus that the data in the fact table isn't stored on that level of detail, or in other words the fact and dimension table don't share the same level of granularity.
    How it should be:
    If you want to get the revenue per product, you will need to have a second fact table "G", which has data which is stored on order line item level. This table contains the following attributes: order_line_item_id, product_id and order_line_item_revenue.
    This will become your diagram on physical level:
    B--<G>--E
    Joins: B.order_line_item_id on G.order_line_item_id and E.product_id on G.product_id
    Table E has become a dimension of fact table G.
    The first physical diagram should look like this:
    A--<D
    If you want you can model both physical diagrams into one logical diagram, assuming that A and D (order dimension and fact table) are aggregates of B and G (order line items dimension and fact table). In that case you should read this blog item: http://obiee101.blogspot.com/2008/11/obiee-making-it-aggregate-aware.html
    Regards,
    Stijn

  • [nQSError: 14065] Illegal cross join

    I am getting the following the following error “[nQSError: 14065] Illegal cross join” in the following situation.
    We have one dimension table Called “WC_CUSTOMER_D” and in that table we are storing 2 row_wids one to store the “Status Wid” (data comes from WC_LOV_D) and “Risk Wid” (again data comes from WC_LOV_D) of the customer . We have 2 alias table as Dim_Status_WC_LOV_D and Dim_Risk_WC_LOV_D and it joins to the Dim_WC_CUSTOMER_D .
    In Logical we have one Logical table “Dim Customer” and has 3 Logical table source (reason is we can write content level filters ) for the each dimension tables. We exposed some attributes from the Dim_WC_CUSTOMER_D, Dim_status_WC_LOV_D and Dim_Risk_WC_LOV_D tables.
    In answer , We are getting the illegal cross join error when we expose fields from 2 WC_LOV_D alias tables
    Error comes only if we use alias of same physical type more than once
    Query Status: Query Failed: [nQSError: 14065] Illegal cross join within the same dimension caused by incorrect subject area setup: [
    WC_CUSTOMER_D T624599,
    WC_LOV_D T624699] with [
    WC_LOV_D T628734]
    But when I add a fact , BI is able to build a query
    select T624599.SOURCE_SYSTEM as c1,
    T624699.LOOKUP_CODE as c2,
    T628734.LOOKUP_CODE as c3,
    count(distinct T623979.CUST_ACCT_WID) as c4
    from
    WC_LOV_D T628734 /* Dim_Risk_WC_LOV_D_ */ ,
    WC_LOV_D T624699 /* Dim_Staus_WC_LOV_D */ ,
    WC_CUSTOMER_D T624599 /* Dim_W_CUSTOMER_D */ ,
    WC_CUSTOMER_F T623979 /* Fact_WC_CUSTOMER_F */
    where ( T623979.CUST_FIN_PROFL_WID = T624599.ROW_WID and T624599.X_ACCOUNT_STATUS_WID = T624699.ROW_WID and T624599.X_RISK_CODE_WID = T628734.ROW_WID and T628734.LOOKUP_TYPE = 'RISK' and T624699.LOOKUP_TYPE = 'STATUS' )
    group by T624599.X_ SOURCE_SYSTEM, T628734.LOOKUP_CODE, T624699.LOOKUP_CODE
    order by c1, c2, c3
    Please guide me if I did some mistake or any work around for this issue.
    Thanks
    Barna

    Hi,
    Maybe you have already resolved this issue. In any case, I found a solution following instructions in support note ID 1329237.1.
    Best regards,
    Cristina

  • [nQSError: 14065] Illegal cross join within the same dimension

    Hey guys,
    I'm stumped. I have two dimension tables that are joined 1:N (there is NOT an M:N relationship between them) and I have them joined in the Physical Layer and the Business Model and Mapping Layer. The two tables are F4101 (the "1") and F4102 (the "N") in the 1:N relationship. F4102 then joins to a fact table, and F4101 joins to NOTHING else. So I don't believe I have a circular condition or a need for a bridge table. Both tables are published to the Presentation Layer for reporting.
    The error occurs in Answers when I want to do something as trivial as display the three primary key columns together from F4101: F4101.col1, F4101.col2, F4101.col3 (all three make up the PK). When I do that, the following error occurs:
    "nQSError: 14065] Illegal cross join within the same dimension caused by incorrect subject area setup: [ F4101 T28761] with [ F4102 T1805] "
    What I can't figure out is WHY the F4102 table is listed in this error. I didn't try to report on it at all. See the logical SQL below from my query:
    "SQL Issued: SELECT "Item Master (F4101)".IMITM saw_0, "Item Master (F4101)".IMLITM saw_1, "Item Master (F4101)".IMAITM saw_2 FROM "Sales Analysis" ORDER BY saw_0, saw_1, saw_2"
    As soon as I take out one of the three PK columns and add in another non-PK column from F4101, it works just fine. And reporting on each of the three PK columns individually works as well in Answers.
    Any ideas? I would greatly appreciate it.
    Thanks.

    Try this;
    1. In the logical layer, create one folder called F4101_F4102.
    2. Map both F4101 and F4102 as logical table sources in that folder.
    3. Join from the folder F4101_F4102 to the fact using a Logical (new complex join) join.
    Chris.

  • Getting Error : Illegal cross join within the same dimension

    Hi All,
    At database there are 4 tables - XLE_Entity_profiles (A) , XLE_ETB_profiles (B) ,XLE_Registration (C),XLE_Reg_Function(D) .
    Attribute info is as below -
    A.Le_name
    B.LRU_name
    C. Registraton name
    D. Function_code
    I have to model a single dimension which contains the attributes from these tables and dimension should also support queries which contains attributes from this dimension only without selecting any fact.
    For Exp - query is as below -
    Le_name,Le-Registraton name,Le_Function_code,LRU_name,LRU_Registraton name,LRU_Function_code
    To support such query , i created aliases of table XLE_Registration,XLE_Reg_Function.
    Aliases names are - XLE_Registration_LE (E),XLE_Registration_LRU (F),XLE_Reg_Function_LE (G).,XLE_Reg_Function_LRU (H)
    Attributes from aliases are as below -
    XLE_Registration_LE- Le-Registraton name
    XLE_Registration_LRU -LRU_Registraton name
    XLE_Reg_Function_LE - Le_Function_code
    XLE_Reg_Function_LRU - LRU_Function_code
    i have renamed the attributes For LE and LRU.
    The Physical layer diagram is as below
    A < B
    E F
    G H
    [A:B (1:M) , A:E(1:M), E:G(1:M),B:F(1:M),F:H(1:M)]
    At logical layer , i have created a dimension DIM-LE with below logical table sources -
    A ,B,E,F,G,H
    Using the properties of LTS B , i mapped B to A.
    Using the properties of LTS E , i mapped E to A.
    Using the properties of LTS F , i mapped F to B.
    Using the properties of LTS G , i mapped G to E.
    Using the properties of LTS H , i mapped H to F.
    Now when i run the query , i am getting the error -
    Query - Le_name,Le-Registraton name,Le_Function_code,LRU_name,LRU_Registraton name,LRU_Function_code
    +++Administrator:2a0000:2a0004:----2008/11/07 19:39:03
    Query Status: Query Failed: [nQSError: 14065|http://forums.oracle.com/forums/] Illegal cross join within the same dimension caused by incorrect subject area setup: [
    XLE_REGISTRATIONS T1218 On XLE_REGISTRATIONS_LRU.REGISTRATION_ID = XLE_REG_FUNCTIONS_LRU.REGISTRATION_ID,
    XLE_REG_FUNCTIONS T5737,
    XLE_ETB_PROFILES T900 On XLE_ETB_PROFILES.ESTABLISHMENT_ID = XLE_REGISTRATIONS_LRU.SOURCE_ID,
    XLE_ENTITY_PROFILES T836 On XLE_ENTITY_PROFILES.LEGAL_ENTITY_ID = XLE_ETB_PROFILES.LEGAL_ENTITY_ID] with [
    XLE_REGISTRATIONS T1155 On XLE_REGISTRATIONS_LE.REGISTRATION_ID = XLE_REG_FUNCTIONS_LE.REGISTRATION_ID,
    XLE_REG_FUNCTIONS T5703,
    XLE_ENTITY_PROFILES T836 On XLE_ENTITY_PROFILES.LEGAL_ENTITY_ID = XLE_REGISTRATIONS_LE.SOURCE_ID]
    But when i run below query,which resembles the BI Answer query, against the database ,
    select distinct A.NAME as c1,
    B.REGISTERED_NAME as c2,
    E.Function_code as c5,
    C.NAME as c3,
    D.REGISTERED_NAME as c4,
    F.Function_code as c6
    from
    XLE_ENTITY_PROFILES A,
    XLE_REGISTRATIONS B,
    XLE_REG_FUNCTIONS E,
    XLE_ETB_PROFILES C,
    XLE_REGISTRATIONS D,
    XLE_REG_FUNCTIONS F
    where (A.LEGAL_ENTITY_ID = C.LEGAL_ENTITY_ID and
    A.LEGAL_ENTITY_ID = B.SOURCE_ID and
    C.ESTABLISHMENT_ID = D.SOURCE_ID and
    B.SOURCE_TABLE = 'XLE_ENTITY_PROFILES' and
    D.SOURCE_TABLE = 'XLE_ETB_PROFILES' and
    E.Registration_id = B.Registration_id and
    F.Registration_id = D.Registration_id)
    order by c1, c2,c5, c3, c4,c6
    i don't get any error.
    Please let me know , why am i getting this error and how can i resolve this issue?

    Hi All,
    Is there any update on this ?
    Thanks,Ashish

  • Can cross join be used with other joins

    hi,
    Q1) is this syntactically correct , cross join with other joins like inner outer. like following.
    select * from t1 cross join t2
    inner join t3 on cast(t3.c1 as varchar) =  (cast(t1.id as varchar) +  cast(t2.t2 as varchar))
    I have seen it works but wanted to know is it syntactically correct.
    yours sincerely

    Hi
    First, Sorry, I wanted to VOTE (as I wrote) and not to Propose as answer :-)
    Join are not necessarily executing in the order we write them. I can show simple example with tables that include the amount of rows is very different.
    /**************************************************** DDL - Create tables */
    CREATE TABLE T1 (
    ID INT IDENTITY CONSTRAINT PK_T1 PRIMARY KEY,
    MyValue UNIQUEIDENTIFIER DEFAULT NEWID()
    CREATE TABLE T2 (
    ID INT IDENTITY CONSTRAINT PK_T2 PRIMARY KEY,
    MyValue UNIQUEIDENTIFIER DEFAULT NEWID()
    CREATE TABLE T3 (
    ID INT IDENTITY CONSTRAINT PK_T3 PRIMARY KEY,
    MyValue UNIQUEIDENTIFIER DEFAULT NEWID()
    GO
    /**************************************************** DML - Populate Tables*/
    SET NOCOUNT ON;
    insert T1 (MyValue)
    select top 100 null
    from _ArielyAccessoriesDB.dbo.ArielyNumbers
    GO
    insert T2 (MyValue)
    select top 500 null
    from _ArielyAccessoriesDB.dbo.ArielyNumbers
    GO
    insert T3 (MyValue)
    select top 10000 null
    from _ArielyAccessoriesDB.dbo.ArielyNumbers
    GO
    /**************************************************** Play Time */
    select T1.MyValue, T2.MyValue, T3.MyValue
    from T3
    join T2 on T2.ID = T3.ID
    join T1 on T1.ID = T2.ID
    GO
    -- Check Execution Plan [EP]
    -- Notice that SQL Server has changed the join order from T3-T2-T1 to T1-T2-T3 because it’s better that way.
    -- You can notice that the order was by the number of rowns in tables from the smallest to the bigest SET
     hope this is helpful :-)
    [Personal Site] [Blog] [Facebook]

  • Cross Join in Power Query

    Is it possible to create a cross join between queries in Power Query?
    I plan to use a table holding budgetlines that i want to cross join with a timetable to create monthly budgetlines.
    Thanks, Menno van Leewen

    Hi Menno,
    Yes, it's possible to perform different kinds of join operations in Power Query, including a cross join. Please check out this page for more information on the different options,
    http://office.microsoft.com/en-us/excel-help/table-join-HA104112136.aspx
    The library specification also contains a description about the different Join Kinds (around page 164):
    http://office.microsoft.com/en-us/excel-help/learn-about-power-query-formulas-HA104003958.aspx?CTT=5
    According to your description, I think you will want to do a full outer join. It should look similar to this:
    Table.Join(Customers, "CustomerID",Table.PrefixColumns(Orders, "Order"), "Order.CustomerID", JoinKind.FullOuter)
    Thanks,
    M.

  • Need help to join two tables using three joins, one of which is a (between) date range.

    I am trying to develop a query in MS Access 2010 to join two tables using three joins, one of which is a (between) date range. The tables are contained in Access. The reason
    the tables are contained in access because they are imported from different ODBC warehouses and the data is formatted for uniformity. I believe this cannot be developed using MS Visual Query Designer. I think writing a query in SQL would be suiting this project.
    ABCPART links to XYZPART. ABCSERIAL links to XYZSERIAL. ABCDATE links to (between) XYZDATE1 and ZYZDATE2.
    [ABCTABLE]
    ABCORDER
    ABCPART
    ABCSERIAL
    ABCDATE
    [ZYXTABLE]
    XYZORDER
    XYZPART
    XYZSERIAL
    XYZDATE1
    XYZDATE2

    Thank you for the looking at the post. The actual table names are rather ambiguous. I renamed them so it would make more sense. I will explain more and give the actual names. What I do not have is the actual data in the table. That is something I don't have
    on this computer. There are no "Null" fields in either of the tables. 
    This table has many orders (MSORDER) that need to match one order (GLORDER) in GLORDR. This is based on MSPART joined to GLPART, MSSERIAL joined to GLSERIAL, and MSOPNDATE joined if it falls between GLSTARTDATE and GLENDDATE.
    [MSORDR]
    MSORDER
    MSPART
    MSSERIAL
    MSOPNDATE
    11111111
    4444444
    55555
    2/4/2015
    22222222
    6666666
    11111
    1/6/2015
    33333333
    6666666
    11111
    3/5/2015
    This table has one order for every part number and every serial number.
    [GLORDR]
    GLORDER
    GLPART
    GLSERIAL
    GLSTARTDATE
    GLENDDATE
    ABC11111
    444444
    55555
    1/2/2015
    4/4/2015
    ABC22222
    666666
    11111
    1/5/2015
    4/10/2015
    AAA11111
    555555
    22222
    3/2/2015
    4/10/2015
    Post Query table
    GLORDER
    MSORDER
    GLSTARTDATE
    GLENDDATE
    MSOPNDATE
    ABC11111
    11111111
    1/2/2015
    4/4/2015
    2/4/2015
    ABC22222
    22222222
    1/5/2015
    4/10/2015
    1/6/2015
    ABC22222
    33333333
    1/5/2015
    4/10/2015
    3/5/2015
    This is the SQL minus the between date join.
    SELECT GLORDR.GLORDER, MSORDR.MSORDER, GLORDR.GLSTARTDATE, GLORDR.GLENDDATE, MSORDR.MSOPNDATE
    FROM GLORDR INNER JOIN MSORDR ON (GLORDR.GLSERIAL = MSORDR.MSSERIAL) AND (GLORDR.GLPART = MSORDR.MSPART);

  • How to create index on XMLTYPE ordered collection table?

    I am using Oracle 11.2.0.2.
    Essentially, my XML documents have a 3-level hierarchy:
    event
      +---action  [1:n]
             +---- param   [1:n]
    I am trying to create indexes on ordered collection tables, but can not get the syntax right...
    I have created a table with an object-relational XMLType column:
    CREATE TABLE T_C_RMP_MNTRNG_XML_FULL_IL4 (
      MESSAGE_ID NUMBER(22,0) NOT NULL ENABLE,
      XML_EVAL_ID NUMBER(22,0),
      VIN7 VARCHAR2(7 BYTE),
      FLEET_ID VARCHAR2(50 BYTE),
      CSC_SW_VERSION VARCHAR2(100 BYTE),
      RECEIVED DATE,
      XML_CONTENT SYS.XMLTYPE ,
      DWH_LM_TS_UTC DATE NOT NULL ENABLE,
      CONSTRAINT PK_C_RMP_MNTRNG_XML_FULL_IL4 PRIMARY KEY (MESSAGE_ID)
    ) NOLOGGING TABLESPACE CATALOG
    VARRAY "XML_CONTENT"."XMLDATA"."action" STORE AS TABLE "T_OR_MON_ACTION" (
      NOLOGGING TABLESPACE "CATALOG"
      VARRAY "param" STORE AS TABLE "T_OR_MON_ACTION_PARAM" (
      NOLOGGING TABLESPACE "CATALOG"
      ) RETURN AS LOCATOR
    ) RETURN AS LOCATOR
    XMLTYPE XML_CONTENT STORE AS OBJECT RELATIONAL XMLSCHEMA "http://mydomain.com/cs.xsd" ELEMENT "monitoring";
    I am running the following SELECT:
    SELECT EVENT_ID, ACTION_SUB_ID, MESSAGE_ID, ACTION_TYPE, UNIXTS_TO_DATE(ACTION_TIMESTAMP) ACTION_TIMESTAMP
    FROM T_C_RMP_MNTRNG_XML_FULL_IL4,
    XMLTABLE(
      'for $i1 in /monitoring ,
      $i2 in $i1/action           
      return element r {             
      $i1/eventId,             
      $i2           
      PASSING XML_CONTENT COLUMNS
      EVENT_ID VARCHAR(40) PATH 'eventId',
      ACTION_SUB_ID INTEGER PATH 'action/actionSubId',
      ACTION_TYPE VARCHAR2(100) PATH 'action/type',
      ACTION_TIMESTAMP NUMBER(13,0) PATH 'action/time'
    ) T2
    WHERE (
      EVENT_ID IS NOT NULL AND ACTION_SUB_ID IS NOT NULL
    The explain plan looks like this (sorry, don't know how to get this formatted any "eye-friendlier"):
    | Id  | Operation          | Name                        | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT   |                             |  1609K|  6316M|       |  6110K  (1)| 20:22:11 |
    |*  1 |  HASH JOIN         |                             |  1609K|  6316M|   111M|  6110K  (1)| 20:22:11 |
    |   2 |   TABLE ACCESS FULL| T_C_RMP_MNTRNG_XML_FULL_IL4 |   582K|   104M|       |  5241   (1)| 00:01:03 |
    |*  3 |   TABLE ACCESS FULL| T_OR_MON_ACTION             |    32M|   117G|       |   105K  (2)| 00:21:08 |
    Predicate Information (identified by operation id):
       1 - access("NESTED_TABLE_ID"="T_C_RMP_MNTRNG_XML_FULL_IL4"."SYS_NC0001300014$")
           filter(CAST(SYS_XQ_UPKXML2SQL(SYS_XQEXVAL(SYS_XQEXTRACT(XMLCONCAT(SYS_XMLGEN("T_C_RMP_MNTRN
                  G_XML_FULL_IL4"."SYS_NC00017$",NULL,SYS_XMLCONV("T_C_RMP_MNTRNG_XML_FULL_IL4"."SYS_NC00012$",0,32,
                  'EC1EEF23FD023A27E04032A06D930A8D',3,3783,1)),SYS_MAKEXML('EC1EEF23FD023A27E04032A06D930A8D',3780,
                  "T_C_RMP_MNTRNG_XML_FULL_IL4"."SYS_NC00008$","SYS_ALIAS_0"."SYS_NC_ROWINFO$")),'/eventId',NULL),0,
                  0,20971520,0),50,1,2) AS VARCHAR(40) ) IS NOT NULL)
       3 - filter(CAST(TO_NUMBER(TO_CHAR("SYS_ALIAS_0"."actionSubId")) AS INTEGER ) IS NOT NULL)
    Note
       - dynamic sampling used for this statement (level=2)
       - Unoptimized XML construct detected (enable XMLOptimizationCheck for more information)
    The XML schema looks like this:
    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" xmlns:oraxdb="http://xmlns.oracle.com/xdb" oraxdb:storeVarrayAsTable="true" oraxdb:flags="2105639" oraxdb:schemaURL="http://mydomain.com/cs.xsd" oraxdb:schemaOwner="MYUSER" oraxdb:numProps="23">
      <xs:element name="monitoring" oraxdb:propNumber="3785" oraxdb:global="true" oraxdb:SQLName="monitoring" oraxdb:SQLType="monitoring755_T" oraxdb:SQLSchema="MYUSER" oraxdb:memType="258" oraxdb:defaultTable="monitoring757_TAB" oraxdb:defaultTableSchema="MYUSER">
        <xs:complexType oraxdb:SQLType="monitoring755_T" oraxdb:SQLSchema="MYUSER">
          <xs:sequence>
            <xs:element maxOccurs="unbounded" ref="action" oraxdb:propNumber="3780" oraxdb:global="false" oraxdb:SQLName="action" oraxdb:SQLType="action752_T" oraxdb:SQLSchema="MYUSER" oraxdb:memType="258" oraxdb:MemInline="false" oraxdb:SQLInline="true" oraxdb:JavaInline="false" oraxdb:SQLCollType="action756_COLL" oraxdb:SQLCollSchema="MYUSER"/>
            <xs:element ref="reservationType" oraxdb:propNumber="3781" oraxdb:global="false" oraxdb:SQLName="reservationType" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:MemInline="false" oraxdb:SQLInline="true" oraxdb:JavaInline="false"/>
            <xs:element ref="softwareVersion" oraxdb:propNumber="3782" oraxdb:global="false" oraxdb:SQLName="softwareVersion" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:MemInline="false" oraxdb:SQLInline="true" oraxdb:JavaInline="false"/>
            <xs:element ref="eventId" oraxdb:propNumber="3783" oraxdb:global="false" oraxdb:SQLName="eventId" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:MemInline="false" oraxdb:SQLInline="true" oraxdb:JavaInline="false"/>
            <xs:element ref="vin" oraxdb:propNumber="3784" oraxdb:global="false" oraxdb:SQLName="vin" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:MemInline="false" oraxdb:SQLInline="true" oraxdb:JavaInline="false"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <xs:element name="action" oraxdb:propNumber="3790" oraxdb:global="true" oraxdb:SQLName="action" oraxdb:SQLType="action752_T" oraxdb:SQLSchema="MYUSER" oraxdb:memType="258" oraxdb:defaultTable="action754_TAB" oraxdb:defaultTableSchema="MYUSER">
        <xs:complexType oraxdb:SQLType="action752_T" oraxdb:SQLSchema="MYUSER">
          <xs:sequence>
            <xs:element ref="type" oraxdb:propNumber="3786" oraxdb:global="false" oraxdb:SQLName="type" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:MemInline="false" oraxdb:SQLInline="true" oraxdb:JavaInline="false"/>
            <xs:element maxOccurs="unbounded" ref="param" oraxdb:propNumber="3787" oraxdb:global="false" oraxdb:SQLName="param" oraxdb:SQLType="param749_T" oraxdb:SQLSchema="MYUSER" oraxdb:memType="258" oraxdb:MemInline="false" oraxdb:SQLInline="true" oraxdb:JavaInline="false" oraxdb:SQLCollType="param753_COLL" oraxdb:SQLCollSchema="MYUSER"/>
            <xs:element ref="actionSubId" oraxdb:propNumber="3788" oraxdb:global="false" oraxdb:SQLName="actionSubId" oraxdb:SQLType="NUMBER" oraxdb:memType="2" oraxdb:MemInline="false" oraxdb:SQLInline="true" oraxdb:JavaInline="false"/>
            <xs:element ref="time" oraxdb:propNumber="3789" oraxdb:global="false" oraxdb:SQLName="time" oraxdb:SQLType="NUMBER" oraxdb:memType="2" oraxdb:MemInline="false" oraxdb:SQLInline="true" oraxdb:JavaInline="false"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <xs:element name="type" type="xs:string" oraxdb:propNumber="3791" oraxdb:global="true" oraxdb:SQLName="type" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:defaultTable="type751_TAB" oraxdb:defaultTableSchema="MYUSER"/>
      <xs:element name="param" oraxdb:propNumber="3794" oraxdb:global="true" oraxdb:SQLName="param" oraxdb:SQLType="param749_T" oraxdb:SQLSchema="MYUSER" oraxdb:memType="258" oraxdb:defaultTable="param750_TAB" oraxdb:defaultTableSchema="MYUSER">
        <xs:complexType oraxdb:SQLType="param749_T" oraxdb:SQLSchema="MYUSER">
          <xs:sequence>
            <xs:element minOccurs="0" ref="value" oraxdb:propNumber="3792" oraxdb:global="false" oraxdb:SQLName="value" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:MemInline="false" oraxdb:SQLInline="true" oraxdb:JavaInline="false"/>
            <xs:element ref="key" oraxdb:propNumber="3793" oraxdb:global="false" oraxdb:SQLName="key" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:MemInline="false" oraxdb:SQLInline="true" oraxdb:JavaInline="false"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <xs:element name="value" type="xs:string" oraxdb:propNumber="3795" oraxdb:global="true" oraxdb:SQLName="value" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:defaultTable="value748_TAB" oraxdb:defaultTableSchema="MYUSER"/>
      <xs:element name="key" type="xs:string" oraxdb:propNumber="3796" oraxdb:global="true" oraxdb:SQLName="key" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:defaultTable="key747_TAB" oraxdb:defaultTableSchema="MYUSER"/>
      <xs:element name="actionSubId" type="xs:integer" oraxdb:propNumber="3797" oraxdb:global="true" oraxdb:SQLName="actionSubId" oraxdb:SQLType="NUMBER" oraxdb:memType="2" oraxdb:defaultTable="actionSubId746_TAB" oraxdb:defaultTableSchema="MYUSER"/>
      <xs:element name="time" type="xs:integer" oraxdb:propNumber="3798" oraxdb:global="true" oraxdb:SQLName="time" oraxdb:SQLType="NUMBER" oraxdb:memType="2" oraxdb:defaultTable="time745_TAB" oraxdb:defaultTableSchema="MYUSER"/>
      <xs:element name="reservationType" type="xs:string" oraxdb:propNumber="3799" oraxdb:global="true" oraxdb:SQLName="reservationType" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:defaultTable="reservationType744_TAB" oraxdb:defaultTableSchema="MYUSER"/>
      <xs:element name="softwareVersion" type="xs:string" oraxdb:propNumber="3800" oraxdb:global="true" oraxdb:SQLName="softwareVersion" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:defaultTable="softwareVersion743_TAB" oraxdb:defaultTableSchema="MYUSER"/>
      <xs:element name="eventId" type="xs:string" oraxdb:propNumber="3801" oraxdb:global="true" oraxdb:SQLName="eventId" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:defaultTable="eventId742_TAB" oraxdb:defaultTableSchema="MYUSER"/>
      <xs:element name="vin" type="xs:string" oraxdb:propNumber="3802" oraxdb:global="true" oraxdb:SQLName="vin" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:defaultTable="vin741_TAB" oraxdb:defaultTableSchema="MYUSER"/>
    </xs:schema>
    How can I create an index on these ordered collection tables in order to improve performance?
    I found the example at http://docs.oracle.com/cd/E11882_01/appdev.112/e23094/xdb_rewrite.htm#ADXDB5859 but am not able to apply it to this particular case...
    Thank you in advance...

    If the schema is not annotated then xs:integer and xs:string are mapped to NUMBER and VARCHAR2(4000) datatypes, so you have to use those in your query in order to avoid unnecessary typecasting operations.
    You should also use chained XMLTABLEs when accessing a parent/child relationship instead of a FLWOR expression, otherwise the CBO may not rewrite the XQuery correctly (maybe it's fixed in the latest release).
    If you make those changes, the plan should show cleaner predicates :
    SQL> SELECT EVENT_ID, ACTION_SUB_ID, MESSAGE_ID, ACTION_TYPE, ACTION_TIMESTAMP
      2  FROM test_table,
      3  XMLTABLE('/monitoring'
      4    PASSING XML_CONTENT COLUMNS
      5      EVENT_ID         VARCHAR2(4000) PATH 'eventId',
      6      actions          XMLTYPE        PATH 'action'
      7    ) T1,
      8  XMLTABLE('/action'
      9    PASSING actions COLUMNS
    10      ACTION_SUB_ID    NUMBER PATH 'actionSubId',
    11      ACTION_TYPE      VARCHAR2(4000) PATH 'type',
    12      ACTION_TIMESTAMP NUMBER PATH 'time'
    13  ) T2
    14  WHERE EVENT_ID IS NOT NULL
    15  AND ACTION_SUB_ID IS NOT NULL
    16  ;
    Execution Plan
    Plan hash value: 1763884463
    | Id  | Operation                    | Name            | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT             |                 |   109 |   220K|     6  (17)| 00:00:01 |
    |   1 |  MERGE JOIN                  |                 |   109 |   220K|     6  (17)| 00:00:01 |
    |*  2 |   TABLE ACCESS BY INDEX ROWID| TEST_TABLE      |    11 |   352 |     2   (0)| 00:00:01 |
    |   3 |    INDEX FULL SCAN           | SYS_C007567     |    11 |       |     1   (0)| 00:00:01 |
    |*  4 |   SORT JOIN                  |                 |   109 |   216K|     4  (25)| 00:00:01 |
    |*  5 |    TABLE ACCESS FULL         | T_OR_MON_ACTION |   109 |   216K|     3   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - filter("TEST_TABLE"."SYS_NC00012$" IS NOT NULL)
       4 - access("SYS_ALIAS_0"."NESTED_TABLE_ID"="TEST_TABLE"."SYS_NC0000800009$")
           filter("SYS_ALIAS_0"."NESTED_TABLE_ID"="TEST_TABLE"."SYS_NC0000800009$")
       5 - filter("SYS_ALIAS_0"."actionSubId" IS NOT NULL)
    Note
       - dynamic sampling used for this statement (level=2)
    Now, if still necessary, it all boils down to choosing a technique to index NULL values :
    - composite index with a not null or constant column
    - FBI
    - bitmap
    Pick one that best fits your data, selectivity and activity on the tables.

  • How to avoid duplicates in CROSS JOIN Query

    Hi,
    I am using CROSS JOIN to get all the subset of a table col values as shown below:
    PRODUCT (Col Header)
    Bag
    Plate
    Biscuit
    While doing cross join we will get as
    Bag Bag
    Bag Plate
    Bag Biscuit
    Plate Bag
    Plate Plate
    Plate Biscuit ..... like this
    By placing where condition prod1 <> prod2 to avoid Bag Bag and Plate Plate values. So the output will be like below
    Bag Plate
    Bag Biscuit
    Plate Bag
    Plate Biscuit
    Now "Bag Plate" and "Plage Bag" are same combination how to avoid these records. My expected result is
    Bag Biscuit
    Plate Biscuit
    How to derive this ?
    Sridhar

    Hi,
    This is the the solution that I found as fit to the OP question, but
    Visakh16 already posted the same idea (assuming the names are unique) from the start and I don't think that anyone notice it!
    Sridhar.DPM did
    you check Visakh16's response
    (the second response received)?!?
    I will mark his response as an answer. If this is not what you need pls clarify and you can unmark it :-)
    [Personal Site] [Blog] [Facebook]

Maybe you are looking for

  • How do I add a hyperlink to an object in Pages '09 - 4.3

    It can be done in Word but seems impossible in Pages.  If anyone knows a way to convert a Word doc to pdf and keep a hyperlink that would be even more useful

  • JDAPI with multi canvas form and LAF questions

    I'm trying to use jdapi to apply LAF project on my forms, it works great with simple forms, but with multi canvases and blocks form it doesn't apply LAF for all of them. I can follow the code of the done one for the rest, but i have questions: do i h

  • Integration kit for SAP Solutions

    Hi gurus, i've encountered a problem with BO XI 3.0 Integration for SAP Solutions. I've installed in a virtual machine BO XI Edge series for NON-SAP solutions evaluation copy,when I try to run web InfoView everything working fine. The infoview path i

  • How to get songs from itunes to ipod shuffle

    I just seem to be having problems finding anything I download in itunes on my ipod shuffle. I am not techo savy at all!

  • (266436851) Q WWSD-45 wsgen vs ant?

    Q<WWSD-45> on wsgen and utility jars, I thought the ear was generated by wsgen and not explicitly by ant even though wsgen is invoked by ant. Is this incorrect? A<WWSD-45> wsgen is an ANT task. That means that the wsgen element in a build.xml file co