Inline query vs cross join
Hi all,
Two tables who have no relation with each other. For example an employees table and a systemparameter table with a startworktime.
We need a query with data from both tables:
Get all employees and the startworktime (which is the same for everybody)
Which is cheaper: an inline query or a cartesian product or crossjoin?
Inine :
select name, function
, (select startworktime from systemparameter)
from employees;
Cartesian product:
select name, function, startwoime
rktfrom employees
cross join systemparameter;
Your thoughts on this.
Hi,
To see which runs faster on your system, with your sub-query, there's no sibstitute for testing on your system, with your sub-query.
I predict you won't notice any difference. Scalar sub-queries (as in your first example) are cached (at least in recent versions of Oracle), so you can include a scalar sub-query in a result set of a million rows, and the sub-query can be executed once, not a million times.
Similar Messages
-
Query regarding Inline Query and a Join.Please see
I have a query regarding Inline Queries
I have 2 tables
TRADE and POSTING
TRADE has Primary Key:id_trade_ref and POSTING has Foriegn.Key: id_trade_ref
id_trade_ref 5V973781B has 5 records in POSTINGS
If i need to join these 2 tables,I use
1) Select t.id_entity,t.id_trade_ref,p.am_stock
from trade t,posting p
where t.id_trade_ref = '5V973781B'
and p.id_trade_ref = '5V973781B'
2) Now I can use the same as an Inline Query:
select
t.id_entity,
t.id_trade_ref,
( select p1.am_stock
from posting p1
where p1.id_entity = t.id_entity
and p1.id_trade_ref= t.id_trade_ref
and p1.id_posting_type in ( 'NEW', 'CAN')
from
trade t
where t.id_entity = 'DBL'
and t.id_trade_ref = '5V973781B'
My Query:
Of the two,which is a better option to use.?
Is Inline a better option or a normal join?I would rewrite the first one to:
Select t.id_entity,t.id_trade_ref,p.am_stock
from trade t,posting p
where t.id_trade_ref = '5V973781B'
and p.id_trade_ref = t.id_trade_ref
This way, you really make the join between the table.
I think the join is better because it uses less code. I do not think you will notice much performance win between one or the other, especially because it concerns only a few rows. -
Error occurred when executing query involving cross join or outer join
Hi,
I tried to execute the following query:
select count(*)
from
po,
invoice,
table(xmlsequence(extract(invoice.content, '/CommercialInvoice/Body/LineItemDetails/LineItem'))) invoice_line_item
where
extractValue(po.content, '/PurchaseOrder/Header/DocumentID/RID') =
extractValue(value(invoice_line_item), '/LineItem/Product/PurchaseOrderIdentifier/documentCreatorIdentifier')(+)
It produced the following error:
Error: ORA-00936: missing expression
Then I change the query to:
select count(*)
from
po left outer join
invoice cross join
table(xmlsequence(extract(invoice.content, '/CommercialInvoice/Body/LineItemDetails/LineItem'))) invoice_line_item
on
extractValue(po.content, '/PurchaseOrder/Header/DocumentID/RID')
= extractValue(value(invoice_line_item), '/LineItem/Product/PurchaseOrderIdentifier/documentCreatorIdentifier')
It produced the following error:
Error: ORA-00904: "INVOICE"."SYS_NC0012900130$": invalid identifier
If I simply the query to:
select 1
from
invoice cross join
table(xmlsequence(extract(invoice.content, '/CommercialInvoice/Body/LineItemDetails/LineItem'))) invoice_line_item
It also produced the following error:
Error: ORA-00904: "INVOICE"."SYS_NC0012900130$": invalid identifier
What is the cause of the problem? How to resolve it?
The version I am using is 10.1.0.2.0 on Windows. Any help would be much appreciated.Hi,
Recently we went for BW upgradatiaon (BI7.0) , the error you are facing could be due to the following issue,
If infoobjects are used in infoset as infoprovider ( in BW3.5) after upgrade this infoobjects will not be selected automatically as infoproviders. So it will not be available for Infoset.
Please check whether any infoobjects are used as infoprovider, if so manually change them as infoprovider ( In BI7) and activate.
Since, few reports are working on the infoset , this could be those reports are not using the fields from the infoobjects. so it is working it seems.
Please check and let me know.
Thanks,
V.Senthil -
Self Joining and Inline Query. A tricky report.
I am stuck with a very tricky situation.Please help.This is PROD issue.
I have written a SQL code which has 1 inline queries,and displays the right results
with the right report output
Dont get confused.Just go thru this.
select pie.id_inst_code,
ISNULL(PN.Active, 0) 'Active',
from position_master_input_event pie,
(select insx.id_inst_xref_type,insx.id_inst_xref,count(*) 'PrimaryListing'
from instrument ins, instrument_xref insx
where ins.id_inst = insx.id_inst
and insx.flg_active = 'Y'
and ins.flg_active = 'Y'
group by insx.id_inst_xref_type,insx.id_inst_xref
)PN
where id_entity = 'AGL'
and pie.id_inst_code *= PN.id_inst_xref
and pie.id_src_inst_code_type*= PN.id_inst_xref_type
group by pie.id_inst_code,PN.Active,
Table :Instrument_xref
id_inst id_inst_xref_type id_inst_xref flg_active
0372285 SE B0DV8Y9 Y
0372285 IS GB00B03MLX29 Y
Table :Instrument
id_inst id_inst_xref_type id_inst_xref flg_active flg_primary_listing
0372285 SE B0DV8Y9 Y N
OUTPUT:
id_inst_xref Active
B0DV8Y9 1
PERFECT.Works fine
2) Now comes the tricky part.:
0372285 also has GB00B03MLX29 which has flg_active to Y and which also maps to 0372285.
Am I right?
New reportOutput
id_inst_xref Active PRIMARY ISIN
B0DV8Y9 1 1
So,now I want a SELF JOIN this way built into the code:
(hardcoded values work)
(i)
select a.id_inst_xref
from instrument_xref a,
instrument_xref b
where b.id_inst_xref ='B0DV8Y9'
and b.id_inst = a.id_inst
and b.id_inst_xref_type in ('SE','IS')
and a.id_inst_xref = 'GB00B03MLX29'
(ii)
select count(*) 'PrimaryISIN'
from instrument ins,
instrument_xref insx
where ins.id_inst = insx.id_inst
and insx.flg_active = 'Y'
and ins.flg_primary_listing = 'Y'
and ins.flg_active = 'Y'
And now LINKING ALL :
select pie.id_inst_code,
ISNULL(PN.Active, 0) 'Active',
from position_master_input_event pie,
(select insx.id_inst_xref_type,insx.id_inst_xref,count(*) 'PrimaryListing'
from instrument ins, instrument_xref insx
where ins.id_inst = insx.id_inst
and insx.flg_active = 'Y'
and ins.flg_active = 'Y'
group by insx.id_inst_xref_type,insx.id_inst_xref
)PN,
(select count(*) 'PrimaryISIN'
from instrument ins,
instrument_xref insx
where ins.id_inst = insx.id_inst
and insx.flg_active = 'Y'
and ins.flg_primary_listing = 'Y'
and ins.flg_active = 'Y'
and insx.id_inst_xref = (
select DISTINCT a.id_inst_xref
from instrument_xref a,
instrument_xref b
where b.id_inst_xref = 'B0DV8Y9'
and b.id_inst = a.id_inst
and b.id_inst_xref_type in ('SE','IS')
and a.id_inst_xref = 'GB00B03MLX29'
where id_entity = 'AGL'
and pie.id_inst_code *= PN.id_inst_xref
and pie.id_src_inst_code_type*= PN.id_inst_xref_type
group by pie.id_inst_code,PN.Active,
THE Self join works fine as long as it is hardcoded.
But assume there can br multiple such situations as the above,and I dont want to
hardcode the values,how can I build the NEW REPORT by SELF JOINING.
Please can someome help.This is a tricky one.
Is there a better way to thisIsn't this the same question as:
Passing values dynamically Froman 'INLINE Query' to a 'SUB QUERY'
and
Another query regarding Inline Query and Self Join and pass Column Values -
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?
AviadHi, 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); -
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 LeewenHi 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. -
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 ?
SridharHi,
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] -
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. -
OBIEE: non empty cross join function problem with some reports
Hi all,
I am getting some problem ,when we are excuting some requests in OBIEE its taking long time , Actually our OBIEE is connected with Essbase when we are generating some reports its taking long time so i captured the Query in OBIEE and Iam excuting that query in Essbase MDX editor
its having the the function " NON EMPTy CROSS JOIN"
which reports having non empty crossjoin function its taking long time so how can i disable this function in OBIEEfor that reports
I dont want to use that function for my reports so how can i do this in OBIEE
your help would be appriciated.
Thanks
Edited by: user8815661 on 26 mai 2010 08:44Any Help
-
Passing values dynamically Froman 'INLINE Query' to a 'SUB QUERY'
If I am using an line query which uses a SELF JOIN subquery
how can I pass the values from the Inline Query to Subquery ?
Is this possible?
SQL...Code
and Inline Queries..
(select count(*) 'PrimaryISIN'
from instrument ins,
instrument_xref insx
where ins.id_inst = insx.id_inst
and insx.flg_active = 'Y'
and ins.id_source ='MF'
and ins.flg_primary_listing = 'Y'
and ins.flg_active = 'Y'
and insx.id_inst_xref = ( select DISTINCT a.id_inst_xref
from instrument_xref a,
instrument_xref b
where b.id_inst_xref ='B0DV8Y9'
and b.id_inst = a.id_inst
and b.id_inst_xref_type in ('SE','IS')
and a.id_inst_xref = 'GB00B03MLX29'
)PISIN2
I am hardcoding the id_inst_xref is the SELF JOIN? Can these be passed dynamically from
the INLINE Query which is invoking the SUB QUERY?Hi, The hardcoded values entered in the SELF JOIN run fine.
Now,I need to pass values dynamically from the INLINE query.
How do I do that?
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,
AshishHi 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
BarnaHi,
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. -
HI,
how we can apply cross joins on select query.plz help me .I am using tables ekko,ekpo and lfa1 .Plz help.Hi Amardeep,
as code given by one of guru's in the above joins statement is good when only if use the KEY-FIELDS in where condition if not it causes performance issue , so that you can use the FOR ALL ENTRIES IN statement which it gives good perfomance.
Table declarations
TABLES: ekko, "Purchasing Document Header
ekpo, "Purchasing Document Item
lfa1. "Vendor Master (General Section)
Declaration of types:
data: BEGIN OF tbl_ekko,
ebeln TYPE ebeln,
lifnr TYPE lifnr,
END OF tbl_ekko.
data: BEGIN OF tbl_ekpo,
ebeln TYPE ebeln,
ebelp TYPE ebelp,
END OF tbl_ekpo.
data: BEGIN OF tbl_lfa1,
lifnr TYPE lifnr
ebelp TYPE ebelp,
END OF tbl_lfa1.
*Selection screen:
PARAMETERS: p_lifnr TYPE lifnr,
p_ebeln type ebeln.
Selection (JOIN):
START-OF-SELECTION.
SELECT lifnr
FROM lfa1
INTO table tbl_lfa1
WHERE lifnr EQ p_lifnr.
if sy-subrc = 0.
sort tbl_lfa1 by lifnr.
endif.
if not tbl_lifnr is initial.
SELECT ebeln lifnr
FROM ekko
INTO table tbl_ekko
FOR ALL INTRIES IN tbl_lfa1
WHERE ebeln EQ p_ebeln
AND lifnr EQ tbl_lfa1-lifnr.
if sy-subrc = 0.
sort tbl_ ekko by ebeln.
endif.
endif.
if not tbl_ekko is initial.
SELECT ebeln ebelp
FROM ekpo
INTO table tbl_ekpo
FOR ALL INTRIES IN tbl_ekko
WHERE ebeln EQ tbl_ekko-eblen.
if sy-subrc = 0.
sort tbl_ ekpo by ebeln.
endif.
endif.
END-OF-SELECTION.
Main program logic:
LOOP AT tbl_ekpo.
read table ekko with key ebeln = tbl_ekpo-ebeln BINARY SEARCH.
if sy-subrc = 0
WRITE: / tbl_ekko-ebeln,
tbl_ekko-ebelp,
tbl_ekpo-lifnr.
endif.
ENDLOOP.
<b>NOTE : use only KEY-FIELDS in WHERE condition for better perfomance</b>
In that above code you can change a/c to ur inputs availabe.
<b>Reward with points if helpful.</b>
Regards,
Vijay -
Fetch multiple rows using cross-join technique
Hello.
Can anyone suggest a method to return 3 rows from a query when only one row would otherwise be returned?
I'm trying to achieve the Logical SQL analog to this -
SELECT x.foo, p.id, p.name FROM people p CROSS JOIN (SELECT 1 AS foo UNION ALL SELECT 2 UNION ALL SELECT 3) x;Reason: I want to force a three (n) row result and use GROUP BY with case statements to create 3-level summary.
Here is a simple Logical SQL expression that works for my OBI setup -
SELECT
"- Nx_CSDG0_Repair_Orders (Depot Repair Views)".Repair_Number saw_0,
"- Nx_CSDG0_Repair_Orders (Depot Repair Views)".SR_Operating_Unit_Name saw_1
FROM
"[Noetix-NoetixGlobalRepository] NoetixViews for Oracle Service"
WHERE
("- Nx_CSDG0_Repair_Orders (Depot Repair Views)".Repair_Number = '338246')But I think I cannot do this -
SELECT
"- Nx_CSDG0_Repair_Orders (Depot Repair Views)".Repair_Number saw_0,
"- Nx_CSDG0_Repair_Orders (Depot Repair Views)".SR_Operating_Unit_Name saw_1
FROM
"[Noetix-NoetixGlobalRepository] NoetixViews for Oracle Service"
CROSS JOIN (SELECT 1 AS foo UNION ALL SELECT 2 UNION ALL SELECT 3)
WHERE
("- Nx_CSDG0_Repair_Orders (Depot Repair Views)".Repair_Number = '338246')But what can I do?
Thank you.
-csHi CSeelig ,
The BI Server uses the ANSI SQL standard. Then all SQL that follows this specification will in OBIEE work.
I have made an example with a densification:
http://gerardnico.com/wiki/dat/obiee/logical_sql/obiee_sql_densification
You will see a cross join to make a densification.
Cheers
Nico
Maybe you are looking for
-
Why, after three months of apple tv working perfectly fine, is it now cutting out constantly and the audio and video out of sinc?
-
How do I get the app again as I have brought the full game once already?
-
Hi All, I'd like to create a mouseover js for two image files. One being the initial image and the second being when it is moused over. I'm wondering where I would put these image files so they can be read and dealt with by the script/snippet. Thanks
-
Register and attend the live or on-demand DENSO webinar and win a YETI cooler!
I would definitely take it to Turner Field when we go watch the Braves and show it off!
-
Effective price within Conditions-Tab of ME2xN
Hey, im using the method CHECK of BADI ME_PROCESS_PO_CUST to run some checks before the save of an PO within TRCode ME21/22/23N. For this purpose i need to have access to the data of the table within the Item-Level-Tab Conditions. For that im using t