Outer join clarification
i have doubt on ouer joins.
may i know the difference between query one and two.
1)
select count(test1.EMPNO)
from test1,
test2
where test1.empno = test2.empno(+)
AND test2.dept(+) = 'SALES'
2)
select count(test1.EMPNO)
from test1,
test2
where test1.empno = test2.empno(+)
AND test2.dept = 'SALES'
In the first query outer join to test2 ( unmatched records from test2) also appears. so nulls ( additional rows) from test2 will come even there no matched department with 'Sales'..
In second. Even outer join happened to test2, there are only rows with sales department will appear.. no additinal rows can be seen
Similar Messages
-
Left Outer Join on same table clarification
HI,
I have a table that gets populated from 3<sup>rd</sup> party system. We don’t have control over it. So, the table has master record (master) and children. Master type is 78 and children’s type is 64. So, it looks like this. In the 3<sup>rd</sup>
party system, if Master transaction gets cancelled, it is recorded as type 178. If child is cancelled, then it is 164. Once the child is cancelled and created again using one process then newly created transaction will have 65 as type. Same thing with Master
cancelled transaction also. It will be 79. So, to summarize:
Master:
Brand New Transaction type = 78
Cancelled Transaction type = 178
Cancelled with creation transaction type = 79
Child:
Brand New Transaction type = 64
Cancelled Transaction type = 164
Cancelled with creation transaction type = 65
I don’t have to bother about master records. I need to focus on only children for my query.
ID
TxnID
Master
Type
TDate
Location
193075
211554
211543
64
20140805
ABC
193076
211555
211543
64
20140805
NBC
193077
211556
211543
64
20140805
ABC
193080
211559
211558
64
20140805
ABC
193081
211562
211561
64
20140805
ABC
193082
211565
211564
64
20140805
CBC
193083
211565
211564
164
20140805
CBC
193084
211566
211564
65
20140805
AZC
--drop
table #Transactions
CREATE
TABLE #Transactions
ID
int,
TxnID
int,
mstTicket
int,
Typecode
int,
Tdate
datetime,
Location
varchar(10)
select
* from
#Transactions
Insert
into #Transactions
(ID,
TxnID,
mstTicket,Typecode,Tdate,Location)
Select 193075, 211554,211543,64,'2014-08-05','ABC'
UNION ALL
Select 193076, 211555,211543, 64,
'2014-08-05',
'NBC' UNION ALL
Select 193077, 211556, 211543, 64,
'2014-08-05',
'ABC' UNION
ALL
Select 193080, 211559, 211558, 64,
'2014-08-05',
'ABC' UNION
ALL
Select 193081, 211562, 211561, 64,
'2014-08-05',
'ABC' UNION
ALL
Select 193082, 211565, 211564, 64,
'2014-08-05',
'CBC' UNION
ALL
Select 193083, 211565, 211564, 164,
'2014-08-05',
'CBC' UNION
ALL
Select 193084, 211566, 211564, 65,
'2014-08-05',
'AZC'
select
T.TxnID,
T.TypeCode,
T.Location,
TL.TxnID
From
#Transactions T
Left Outer
JOIN #Transactions
TL ON
TL.TxnID
= T.TxnID
and TL.TypeCode
= 164
select
T.TxnID,
T.TypeCode,
T.Location,
TL.TxnID
From
#Transactions T
Left Outer
JOIN #Transactions
TL ON
TL.TxnID
= T.TxnID
and TL.TypeCode
= 164
Where
T.typecode
in (64, 65)
I need a clarification regarding left Outer Join.
In the first left outer join query both 64 and 164 both have TL.TxnID populated. Why is that?. What I understand from
left outer join is that ‘Returns all the rows’ from left table and only matching data from right table.
Here, matching row from right table is 211565 and 164 record (id 193083). So, only it should have TxnID populated. But row 211565 and 64 has TL.txnID getting populated (ID 193082).
Why is it? Am I not understanding left out join properly?
Thanks,Thank you Shailesh. I understood what join does in left outer join. I was thinking
Left Outer JOIN #Transactions TL ON TL.TxnID = T.TxnID and TL.TypeCode = 164 is same as
Left Outer JOIN #Transactions TL ON TL.TxnID = T.TxnID and TL.TypeCode = T.TypeCode
and TL.TypeCode = 164
#Transactions
T
Left
Outer
JOIN
#Transactions
TL
ON
TL.TxnID
=
T.TxnID
and
TL.TypeCode
= 164
Where
T.typecode
in
(64,
65) -
Inner join and outer join in infosets
hi everyone,
i have a doubt in infosets...
when and why we use inner and outer joins(right outer join and left outer join) for infoset
please give a real time scenario........
Thanks in advance.
Bye.Hello,
Inner join:
For example, the requirement is to show all sales documents where you have delivery exists. In this case, you join both sales ods and delivery ods in a infoset as inner join. This will match the record against the reference documents and pull only matched records.
Outer Join:
Suppose you want to pull all billing/invoice details along with their FI documents related data in a report. Assume that always there might be a situation that invoice exists but not posted to FI, however, you want to have all billing documents details either it has FI document or not. In this case, you link both Billing data and FI document data in a outer join. This will pull all invoices data either FI document exists or not. Other words, you want to show one side of data always but adding additional details from differenent source if data exists.
Hope, it clarifies your doubt. Let me know if any questions.
Thanks
Viswa -
The following code is an example of how to perform an outer join, in this case with ReportQuery (thanks Doug):
ExpressionBuilder eb = new ExpressionBuilder();
ReportQuery rq = new ReportQuery(Employee.class, eb);
rq.addAttribute("firstName");
rq.addAttribute("lastName");
rq.addAttribute("areaCode", eb.anyOfAllowingNone("phoneNumbers").get("areaCode"));
List<ReportQueryResult> results = (List<ReportQueryResult>) session.executeQuery(rq);My question is about the logic Toplink uses to generate the outer join statement with the "(+)" in the generated sql.
Does Toplink only generate the join statement if the same attribute is chosen in the select statement (in the above example "areaCode")?
Along the same line of questioning, does it matter which attribute was in the get() call? So, in the above example did it have to be areaCode, or could it have been any other attribute of phoneNumber, and it still would have performed the join?
In my case, because the selection attributes are built up dynamicly, should I add all attributes of my child class (my equivalent PhoneNumber class)?Thanks for your reply Doug.
One last question, hopefully.
I have a parent table with 2 child tables. When attempting an outer join with both, toplink does not attempt to outer join either. I understand why, sort of - as you get an error when attempting this in sqlplus with "(+)" syntax.
I understand that you can outer join > 1 other table to a parent with ansi sql syntax:
select dept.*,emp.*
from dept left outer join emp
on dept.deptno = emp.deptnoWill toplink allow > 1 child table outer join to a parent table? -
dear all,
since the column of table can not be boolean value, so why and can be used in join query, why "or" can not? anybody can give some example whether "and", "or" used in outer join is correct or wrong.
thanks,hai lily...
yes i have tried this example
in outer join,yes it is correct,if we want
srpecific data then we can use these
parameters ....
hope u get it..
bye -
Full outer Join:ORA-01790
Hi All,
The issue may be silly, but we cant make it out:
DB : Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - ProdWe are running the below query with no issues:
select t1.text,t2.text text2,t1.line,decode(upper(t1.text),upper(t2.text),1,0) flg
from
(select text,row_number() over(order by line) line
from user_source
where name = 'COLL_MVIEW_REFRESH_PROC_LBK'
and replace(trim(text),chr(10)) is not null
) t1,
(select text ,row_number() over(order by line) line
from user_source
where name = 'COLL_MVIEW_REFRESH_PROC'
and trim(replace(text,chr(10))) is not null) t2
where t1.line = t2.lineBut when trying for an outer join it is giving error like
ORA-01790: expression must have same datatype as corresponding expressionOuter Join Query:
select t1.text,t2.text,t1.line,decode(upper(t1.text),upper(t2.text),1,0) flg
from
(select text,row_number() over(order by line) line
from user_source
where name = 'COLL_MVIEW_REFRESH_PROC_LBK'
and replace(trim(text),chr(10)) is not null
) t1 full outer join
(select text ,row_number() over(order by line) line
from user_source
where name = 'COLL_MVIEW_REFRESH_PROC'
and trim(replace(text,chr(10))) is not null) t2
on( t1.line = t2.line )Any idea what is wrong here?
Thanks,
JeneeshNot sure what is wrong with your version. It might have to do with row_number not working on an empty row (outer joined).
How about this alternative?
The approach is a bit different, but it uses only one access to the user_source view.
select s.lineNo, min(s.text1) text1, min(s.text2) text2, decode(upper(min(s.text1)), upper(min(s.text2)), 1, 0) flag
from
(select decode(u.name, 'COLL_MVIEW_REFRESH_PROC_LBK', u.text) text1
,decode(u.name, 'COLL_MVIEW_REFRESH_PROC'
, u.text) text2
,u.name,
row_number() over (partition by u.name order by u.line) lineNo
from user_source u
where u.name in ('COLL_MVIEW_REFRESH_PROC_LBK','COLL_MVIEW_REFRESH_PROC'
/* and u.TYPE = 'PROCEDURE' */
and replace(trim(u.text),chr(10)) is not null
) s
group by s.lineNo
order by s.lineNo;Edited by: Sven W. on Nov 18, 2008 5:24 PM -
How do I find missing entries in outer join table?
Hi all,
I am trying to find records in table1 that are missing in table2. This is a simple process in SQL, but ABAP is giving me trouble. I want to do this using an outer join.
Example:
Select table1~docnumber
From table1
Left Outer Join table2
On table1docnumber = table2docnumber
Where table2~docnumber IS NULL. (the record is missing in table2)
Note: ABAP gives an error and wants me to use the Having Clause, which is ok, but then ABAP wants me to use Group By, which ok, but then I still get the same syntex error.
Any thoughts on doing this with the outer join and is null options. I do not want to select into two internal tables and compare them.All,
I am not trying to do a subquery. Just a simple outer join where I know some records are missing in the second table.
Here is the code:
select eban~banfn
into table i_delay_banfn
from eban
left outer join zsmt_prdelay_upd
on eban~banfn = zsmt_prdelay_upd~banfn
where zsmt_prdelay_upd~banfn IS NULL.
Here is the error message:
No fields from the right-hand table of a LEFT OUTER JOIN may appear in
the WHERE condition: "ZSMT_PRDELAY_UPD~BANFN".
select eban~banfn
into table i_delay_banfn
from eban
left outer join zsmt_prdelay_upd
on eban~banfn = zsmt_prdelay_upd~banfn
having zsmt_prdelay_upd~banfn IS NULL.
Please use code tags
Edited by: Rob Burbank on Mar 5, 2009 12:20 PM -
BI 7.0 Infoset - Infocube - Left outer join - query
Hi Expert,
A infoset contain Infocube and ODS, linked with left outer join, common fields are PO,PO item. PO account assignment ODS have three keyfields: PO Doc.,Item,account Assignment .
PO Infocube <b>PO Account Assignment ODS</b>
PO PO item Amt<b>PO Doc. Item AccAssignment Cost object</b>
1000 10 230 <b>1000 10 1 CC1</b>
1001 10 250 <b>1002 10 1 CC1</b>
1002 10 150 <b>1002 10 2 CC2</b>
in BEx result are like this:
1000 10 230 1 CC1
1001 10 250 # #
1002 10 150 1 CC1
1002 10 150 2 CC2 ( amount only duplicated)
The issue was that amount gets duplicated. It only occurs if PO has more than one account assignment.
In report, we want show like this
1000 10 230 1 CC1
1001 10 250 # #
1002 10 150 1 CC1
1002 10 # 2 CC2
Any suggestion or input to overcome this issue?
Thanks,
Saran
Message was edited by:
Saravanan KHi,
did you solve your problem? because I have the same issue right now: the left outer join doesn't seem to do its job.
Let me know if you have found a solution, it would be appreciated.
have a nice day,
Dominic -
BI Infoset left outer join (NW04s)
I created an Infoset using a left outer join for infoproviders:
- 0FIGL_O10 (GL transaction figures - DSO )
- 0CCA_C03 (CCA Statistical key figures - CUBE)
DSO 0FIGL_O10 is the left table with joins on:
- 0COSTCENTER
- 0FISCPER
The data set returned by Infoset appears to be based on a SQL using an
inner join.
This appears to be a bug.
We are on BI 700 SP 15.Hi Raynald - I did a demo with few records and it works fine for me. We are on 7, SP14.
-
Hi, all
Is it possible to make FULL OUTER JOIN in BI InfoSet?
If no, another question - is it possible to switch base InfoProvider? I have an InfoSet with InfoCube1 and DSO1 which I can outer join. I want to outer join InfoCube1 , not DSO1 that's why I need to switch them in the InfoSet.Hi,
In BI 7.0 Infoset has given chance to include an Info cube also,maximum you can include 2 info Cubes only in a infoset.
check the below link which helps you in understanding of the join conditions so that you can apply to your scenario.
http://help.sap.com/saphelp_nw2004s/helpdata/en/f1/713c3b35703079e10000000a114084/content.htm
http://help.sap.com/saphelp_nw2004s/helpdata/en/67/7e4b3eaf72561ee10000000a114084/content.htm
Regards,
Praveena. -
Left Outer Join Not working in BI 7.0 Infoset
Hi All,
I am working on BI 7.0. I have to create a report where I have to display the Target values from a target DSO against the transactional data (Operational data).
I have a DSO where for a subteam value target has been set up on different KPIs.
In the Info Cube, I have transactional data on daily basis per subteam. I have to show the actual and target values.
I have created an Info Set using Target DSO and Daily operational cube, so that I should able to compare the target and actual values of KPIs, for all the subteam values (From DSO, irrespective of whether the data is available in cube for those sub team).
I have used Outer Left Join in the Info set (DSO on left side), but I am unable to see the desired results. It is working just like an inner join.
Any Idea why the Outer Left Join is not working? The DSO has only one fey field called subteam on which I have set outer left join.
Regards,
AmitHi,
did you solve your problem? because I have the same issue right now: the left outer join doesn't seem to do its job.
Let me know if you have found a solution, it would be appreciated.
have a nice day,
Dominic -
BI 7.0 Left outer join in Infoset
Hi Everybody,
I am using BI 7.0 and have two cubes in my Infoset.
How do we set left outer join option in Infoset.
Thanks
ShilpaLook at <a href="http://help.sap.com/saphelp_nw2004s/helpdata/EN/05/7ce2416149c717e10000000a155106/frameset.htm">this</a> page. Note the text: <i>For performance reasons, you cannot define an InfoCube as the right operand of a left outer join.</i> Hope this helps...
-
Issues with using Outer join in Data Template
Hi all,
this is my data in two tables .
Table Ronny1
colA colB
1 u
2 v
3 x
Table Ronny2
colC colD
1 q
2 r
This is my data template
<dataTemplate name="MGF" dataSourceRef="Source1">
<dataQuery>
<sqlStatement name="Q1" dataSourceRef="Source1">
<![CDATA[select C, D from Ronny2]]>
</sqlStatement>
<sqlStatement name="Q2" dataSourceRef="Source2">
<![CDATA[select A , B from lokesh1 where A = :C]]>
</sqlStatement>
</dataQuery>
<dataStructure>
<group name="G1" source="Q1">
<group name="G2" source="Q2">
<element name="A" value="A"/>
<element name="B" value="B"/>
</group>
</group>
</dataStructure>
</dataTemplate>
Now this would give me result as
A B
1 u
2 v
however my requirement is this
A B
1 u
2 v
3 x
that is, i want to display all the rows of table Ronny1 and matching rows from table Ronny2. I tried modifiying my second sql as
<![CDATA[select A , B from lokesh1 where A = :C (+)]]> ( using a outer join)
but this does give me correct data and comes back with the cartesion product.
Can anyone please answer this for me that how can we use the outer join in data templaes.
Thanks
Ronnyhey vetsrini,
sorry for the confusion here,
actually i want to display all the rows from table Ronny1 and i am also pulling in the matching rows from table Ronny2 and my data structure looks as ( pulling in column D from table Ronny2)
<dataStructure>
<group name="G1" source="Q1">
<group name="G2" source="Q2">
<element name="A" value="A"/>
<element name="B" value="B"/>
<element name="D" value="D"/>
</group>
</group>
</dataStructure>
and this is what i want the output to be
A B D
1 u q
2 v r
3 x
Hence the row where A <> C the data in the D column will be null, same as in the case of outer join.
any suggestions
Thx
Ronny -
Problem with XMLTABLE and LEFT OUTER JOIN
Hi all.
I have one problem with XMLTABLE and LEFT OUTER JOIN, in 11g it returns correct result but in 10g it doesn't, it is trated as INNER JOIN.
SELECT * FROM v$version;
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
PL/SQL Release 11.2.0.1.0 - Production
"CORE 11.2.0.1.0 Production"
TNS for Linux: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
--test for 11g
CREATE TABLE XML_TEST(
ID NUMBER(2,0),
XML XMLTYPE
INSERT INTO XML_TEST
VALUES
1,
XMLTYPE
<msg>
<data>
<fields>
<id>g1</id>
<dat>data1</dat>
</fields>
</data>
</msg>
INSERT INTO XML_TEST
VALUES
2,
XMLTYPE
<msg>
<data>
<fields>
<id>g2</id>
<dat>data2</dat>
</fields>
</data>
</msg>
INSERT INTO XML_TEST
VALUES
3,
XMLTYPE
<msg>
<data>
<fields>
<id>g3</id>
<dat>data3</dat>
</fields>
<fields>
<id>g4</id>
<dat>data4</dat>
</fields>
<fields>
<dat>data5</dat>
</fields>
</data>
</msg>
SELECT
t.id,
x.dat,
y.seqno,
y.id_real
FROM
xml_test t,
XMLTABLE
'/msg/data/fields'
passing t.xml
columns
dat VARCHAR2(10) path 'dat',
id XMLTYPE path 'id'
)x LEFT OUTER JOIN
XMLTABLE
'id'
passing x.id
columns
seqno FOR ORDINALITY,
id_real VARCHAR2(30) PATH '.'
)y ON 1=1
ID DAT SEQNO ID_REAL
1 data1 1 g1
2 data2 1 g2
3 data3 1 g3
3 data4 1 g4
3 data5 Here's everything fine, now the problem:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi
PL/SQL Release 10.2.0.1.0 - Production
"CORE 10.2.0.1.0 Production"
TNS for HPUX: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
--exactly the same environment as 11g (tables and rows)
SELECT
t.id,
x.dat,
y.seqno,
y.id_real
FROM
xml_test t,
XMLTABLE
'/msg/data/fields'
passing t.xml
columns
dat VARCHAR2(10) path 'dat',
id XMLTYPE path 'id'
)x LEFT OUTER JOIN
XMLTABLE
'id'
passing x.id
columns
seqno FOR ORDINALITY,
id_real VARCHAR2(30) PATH '.'
)y ON 1=1
ID DAT SEQNO ID_REAL
1 data1 1 g1
2 data2 1 g2
3 data3 1 g3
3 data4 1 g4As you can see in 10g I don't have the last row, it seems that Oracle 10g doesn't recognize the LEFT OUTER JOIN.
Is this a bug?, Metalink says that sometimes we can have an ORA-0600 but in this case there is no error returned, just incorrect results.
Please help.
Regards.Hi A_Non.
Thanks a lot, I tried with this:
SELECT
t.id,
x.dat,
y.seqno,
y.id_real
FROM
xml_test t,
XMLTABLE
'/msg/data/fields'
passing t.xml
columns
dat VARCHAR2(10) path 'dat',
id XMLTYPE path 'id'
)x,
XMLTABLE
'id'
passing x.id
columns
seqno FOR ORDINALITY,
id_real VARCHAR2(30) PATH '.'
)(+) y ;And is giving me the complete output.
Thanks again.
Regards. -
Tables
Normal EMP TABLE and dept TABLE
query
SELECT e.deptno,d.dname
FROM emp e , dept d
WHERE E.DEPTNO(+)=D.DEPTNO
AND (e.deptno=20 or e.job='CLERK')
question
When i use the above query i cannot get the extra records from dept table( 40 , OPERATIONS) due to a condition
as long as it is "OR" we cannot use outer joins.
Regardless of that condition i need to get that record(40,OPERATION)
Please reply me it is very urgent for my work now..
regards
Boopathiselect e.deptno,d.dname
FROM emp e , dept d
WHERE E.DEPTNO(+)=D.DEPTNO
AND (e.deptno=20 or e.job='CLERK')
This will only fetch the record for 20, IF you want for deptno 40 then you should remove your AND clause (AND (e.deptno=20 or e.job='CLERK'))
select * from dept
===========
DNAME DEPTNO
OPERATION 20
FINANCE 40
TRADE 22
select * from emp
===========
ENAME DEPTNO JOB
a 20 CLERK
b 22 XXX
select e.deptno,d.dname
FROM emp e , dept d
WHERE e.DEPTNO(+)=d.DEPTNO
=======================
DEPTNO DNAME
20 OPERATION
22 TRADE
FINANCE--- This is the one which does not ahve a record in emp but is there in dept hence it has been returned
Maybe you are looking for
-
So firefox 4 crashes when opening in-browser pdfs and a whole host of other sites, even with no addons running. I've found a fix: start in safe mode, then close and open in normal mode. This always solves the problem. But '''why?''' What is causing t
-
Brand New IPod touch bought at BestBuy- Unopened -Want to Return-Question
Hi I bought a new Ipod Touch at BestBuy32g, along with accessories like Cases, portable speaker for Ipod etc., They are all unopened. I have a receipt too.And it's only 7 days since I bought them. I changed my mind and want to return it now. Will the
-
Viber not sending photos from photo gallery
Viber is currently not working on my iphone 4. When trying to send a picture message, it says I am currently not able to access my photo gallery. I get the message "this app does not have access to your photos or videos. You can enable access in Priv
-
Outlook 2010 unter Exchange 2010: Kontakte nach Excel exportieren
Hi all, a user wants to export contacts from a shared folder to Excel. He gets following error message: "An ODBC error has occurred in the Microsoft Excel 97-2003 translator while opening a file to build a field map. [Microsoft] [ODBC Driver Manager]
-
HT201263 My iPod is stuck on the "Plug into iTunes" screen. What do I do???
So, my computer is telling me that I need to type in my password into my iPod to unlock it, but my iPod is telling me to "Plug into Tunes". I can't unlock it on my iPod and I've already tried putting it into recovery mode (or whatever you call it) mu