Equi Join and Outer join using outer keyword
Hi,
First lets take the create statment for scott schema.
create table scott.emp_details(empno number, bonus_date date);
Insert Into Scott.Emp_Details Values(7369, To_Date('01-jan-2013'));
Insert Into Scott.Emp_Details Values(7499, To_Date('05-jan-2013'));
Insert Into Scott.Emp_Details Values(7521, To_Date('10-jan-2013'));
Insert Into Scott.Emp_Details Values(7566, To_Date('01-feb-2013'));
Insert Into Scott.Emp_Details Values(7654, To_Date('05-feb-2013'));
commit;lets also consider the basic scott.emp and scott.dept tables
Now I would like to equi join emp table deptno col with dept table deptno col and left outer join emp table hiredate with emp_details bonus_date and empno col in emp_details can be joined(Equi Join) with empno col of emp table if needed .The outer join has to be placed using the keyword (left/right)outer join
The select statement can have all the detials of emp table .The requirement may look weird but we have some such requirement.
Please suggest
Hi,
sri wrote:
Hi,
First lets take the create statment for scott schema.
create table scott.emp_details(empno number, bonus_date date);
Insert Into Scott.Emp_Details Values(7369, To_Date('01-jan-2013'));
Insert Into Scott.Emp_Details Values(7499, To_Date('05-jan-2013'));
Insert Into Scott.Emp_Details Values(7521, To_Date('10-jan-2013'));
Insert Into Scott.Emp_Details Values(7566, To_Date('01-feb-2013'));
Insert Into Scott.Emp_Details Values(7654, To_Date('05-feb-2013'));
commit;
It's best not to create your own tables in Oracle-supplied schemas, such as SCOTT. Use your own schema for your own tables.
lets also consider the basic scott.emp and scott.dept tablesI see; you're using the standard scott,emp and scott.dept tables, plus the emp_details table you posted above.
Now I would like to equi join emp table deptno col with dept table deptno col and left outer join emp table hiredate with emp_details bonus_date and empno col in emp_details can be joined(Equi Join) with empno col of emp table if needed .The outer join has to be placed using the keyword (left/right)outer join
The select statement can have all the detials of emp table .The requirement may look weird but we have some such requirement.
Please suggestThanks for posting the sample data. Don't forget to post the exact output you want from that sample data.
Do you want something like this?
` EMPNO ENAME DEPTNO DNAME BONUS_DAT
7369 SMITH 20 RESEARCH 01-JAN-13
7499 ALLEN 30 SALES 05-JAN-13
7521 WARD 30 SALES 10-JAN-13
7566 JONES 20 RESEARCH 01-FEB-13
7654 MARTIN 30 SALES 05-FEB-13
7698 BLAKE 30 SALES
7782 CLARK 10 ACCOUNTING
7788 SCOTT 20 RESEARCH
7839 KING 10 ACCOUNTING
7844 TURNER 30 SALES
7876 ADAMS 20 RESEARCH
7900 JAMES 30 SALES
7902 FORD 20 RESEARCH
7934 MILLER 10 ACCOUNTING
40 OPERATIONSIf so, here's one way to do it:
SELECT e.empno, e.ename -- or whatever columns you want
, d.deptno, d.dname -- or whatever columns you want
, ed.bonus_date
FROM scott.dept d
LEFT OUTER JOIN scott.emp e ON e.deptno = d.deptno
LEFT OUTER JOIN emp_details ed ON ed.empno = e.empno
ORDER BY e.empno
;
Similar Messages
-
Hi,
I need to join three tables, based on some conditions (EKPO, EKBE and EKKN Note: All PO line items from EKPO will have a movement associated in the EKBE Table. Capture all PO line items where no matches found in the EKPO-EKBE join)
for the above requirement shall I write my query like this?
SELECT ekpo~ebeln
ekpo~ebelp
ekpo~loekz
ekpo~txz01
ekpo~matnr
ekpo~bukrs
ekpo~werks
ekpo~menge
ekpo~meins
ekpo~knttp
ekbe~vgabe
ekbe~bwart
ekbe~menge
ekbe~dmbtr
ekbe~shkzg
ekkn~sakto
ekkn~kostl
ekkn~ps_psp_pnr
INTO CORRESPONDING FIELDS OF TABLE i_podata
FROM ekpo LEFT OUTER JOIN ekbe ON ekbeebeln = ekpoebeln AND
ekbeebelp = ekpoebelp
INNER JOIN ekkn ON ekknebeln = ekpoebeln AND
ekknebelp = ekpoebelp
WHERE ekpo~werks IN s_werks AND
ekpo~ebeln IN s_ebeln.
Shall I use both Outer Join and Inner join in one Query?
Please correcte me.
Thanks
Frank RexHi,
You can use both inner join and outer join in the same select statement.
Ensure first all the inner joins between tables are declared and put the left outer join at the end.
Some sample code for your reference:
SELECT
AVBELN AKUNNR ABSTNK ABSTDK AVKORG AVTWEG AAUART AKNUMV
BPOSNR BMATNR BWERKS BSPART BLGORT BKZWI1
SUM( BKWMENG ) AS KWMENG DBZIRK D~VKGRP
EDISPO EPRCTR
FROM VBAK AS A INNER JOIN VBAP AS B ON AVBELN EQ BVBELN
INNER JOIN VBPA AS C ON CVBELN EQ BVBELN
INNER JOIN KNVV AS D ON DKUNNR EQ AKUNNR
AND DVKORG EQ AVKORG AND DVTWEG EQ AVTWEG
LEFT OUTER JOIN MARC AS E ON E~MATNR EQ
BMATNR AND EWERKS EQ B~WERKS
INTO CORRESPONDING FIELDS OF TABLE IT_ORDERS
WHERE A~VKORG IN SO_VKORG
AND A~VTWEG IN SO_VTWEG
AND A~KUNNR IN SO_KUNNR
AND A~ERDAT IN SO_ERDAT
AND A~AUART IN ('ZFOR','ZROR','ZEOR','ZDXR','ZXOR','ZRM1','ZGOR','ZSOR')
AND B~MATNR IN SO_MATNR
AND B~WERKS IN SO_WERKS
AND B~SPART IN SO_SPART
AND B~ABGRU EQ SPACE
AND A~LIFSK EQ SPACE
AND A~FAKSK EQ SPACE
AND B~VSTEL IN SO_VSTEL
AND B~LGORT IN SO_LGORT
AND C~KUNNR IN SO_SHIP
AND C~PARVW EQ 'WE'
AND D~VKGRP IN SO_VKGRP
AND D~BZIRK IN SO_BZIRK
AND B~LGORT NE '0950'
GROUP BY AVBELN AKUNNR ABSTNK ABSTDK
AVKORG AVTWEG AAUART AKNUMV B~POSNR
BMATNR BWERKS BSPART BKZWI1 D~BZIRK
DVKGRP BLGORT EDISPO EPRCTR E~MATGR.
Lakshminarayanan.
P.S.Mark all helpful answers for points. -
Hi All,
We are migrating from on-premise SharPoint 2010 to SharePoint online 2013.
I have few questions below:
What are the possibilities and limitations of using Out of the box content search webpart?
Also, how the cross site publishing will work in SharePoint online something with managed navigations and product catalog apporach? if it is not supported, then what are the alternatives to acheive the same?
Appriciate any commnets/clarifications.Thanks in advance.
Thanks,
Dhananjay.Here are the possibilities of Content search webparts
http://office.microsoft.com/en-in/office365-sharepoint-online-enterprise-help/configure-a-content-search-web-part-in-sharepoint-HA104119042.aspx
http://office.microsoft.com/en-in/office365-sharepoint-online-enterprise-help/when-to-use-the-content-query-web-part-or-the-content-search-web-part-in-sharepoint-HA104206662.aspx
Compare the strengths and limitations of the Web Parts
It’s important that you understand the strengths and limitations of the two Web Parts because if you choose the wrong one, your site could run into performance problems. You can use both Web Parts to show content that is based on a query. In a simplified
world, here’s how you can decide between the two:
Use the CQWP when you have a limited amount of content, your query is simple, and you don’t expect your content to grow much in the future.
Use the CSWP in all other scenarios when you want to show content that is based on a query.
The table below gives a comparison of the two Web Parts:
Web Part behavior
Content Query Web Part
Content Search Web Part
Query configuration
Easy
You’ll need to know about certain search features such as
managed properties.
Query across large amounts of content
Limited
Yes
Handle complex queries
Limited
Yes
Scale to handle future content growth
Limited
Yes
Display content from other site collections
No
Yes (see
section below)
Design of query results can be customized
Yes, by using XSLT.
Yes, by using HTML.
Maintenance cost in a complex site architecture
High
Small (see
section below)
Narrow down the query results that are displayed in the Web Part
No
Yes, in combination with the
Refinement Web Part.
It was not there previously but then it was added to Office 365
http://blogs.office.com/2013/10/29/search-innovations-for-site-and-portal-design-in-sharepoint-online/
If this helped you resolve your issue, please mark it Answered -
Difference between physical join and logical join
Hi Gurus,
Can anyone tell me what is the difference between physical join and logical join
Thanks,
ChandraHi,
A physical join is at the physical layer and defines the join between two physical tables. Logical joins live at the BMM (logical) layer and define a join between two logical tables.
The important differentiation is that at the BMM layer you do not tell the OBIEE server how to do the join, you just tell it that there is a relationship between these two logical entities. When the server comes to this logical join it will use the information in the physical joins and decides how the two logical tables are joined together.
In BMM you use complex joins to establish which logical tables are joined which another, the OBI EE server will go to the physical level to search the physical join to make the query. You can also use physical joins in the BMM to override the join in the physical layer but only in very specific conditions.
If you also set complex join in the physical layer OBI EE won't be able to construct the physical query.
Hope this answers your question.
Award points if helpful.
Thanks,
-Amith. -
What are the pros and cons of using people keywords, given that my catalog is already up to date with regular keywording of all subjects? e.g., will the people keyword transfer to other programs?, can I use the same name for a people keyword and regular keyword in the same photo?
What are the pros and cons of using people keywords, given that my catalog is already up to date with regular keywording of all subjects? e.g., will the people keyword transfer to other programs?, can I use the same name for a people keyword and regular keyword in the same photo?
-
Nested loop, merge join and harsh join
Can any one tell me the difference/relationship between nested loop, harsh join and merge join...Thanx
Check Oracle Performance Tuning Guide
13.6 Understanding Joins
http://download-west.oracle.com/docs/cd/B19306_01/server.102/b14211/optimops.htm#i51523 -
Both equii join and natural join are equall.will both display same output
both equii join and natural join are equall.will both display same
output?Hi ,
What is preventing you to do a small test and check yourself?
See the below link.
http://psoug.org/reference/joins.html
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> CREATE TABLE parents (
2 person_id NUMBER(5),
3 adult_name VARCHAR2(20),
4 comments VARCHAR2(40))
5 PCTFREE 0;
Table created.
SQL>
SQL> CREATE TABLE children (
2 parent_id NUMBER(5),
3 person_id NUMBER(5),
4 child_name VARCHAR2(20),
5 comments VARCHAR2(40))
6 PCTFREE 0;
Table created.
SQL>
SQL> INSERT INTO parents VALUES (1, 'Dan', 'So What');
1 row created.
SQL> INSERT INTO parents VALUES (2, 'Jack', 'Who Cares');
1 row created.
SQL> INSERT INTO children VALUES (1, 2, 'Anne', 'Who Cares');
1 row created.
SQL> INSERT INTO children VALUES (1, 1, 'Julia', 'Yeah Right');
1 row created.
SQL> INSERT INTO children VALUES (2, 1, 'Marcella', 'So What');
1 row created.
SQL> COMMIT;
Commit complete.
SQL>
SQL> SELECT adult_name, child_name
2 FROM parents NATURAL JOIN children;
ADULT_NAME CHILD_NAME
Jack Anne
Dan Marcella
SQL> select adult_name,child_name from parents a, children b
2 where a.person_id=b.person_id;
ADULT_NAME CHILD_NAME
Jack Anne
Dan Julia
Dan Marcella
SQL> ed
Wrote file afiedt.buf
1 select adult_name,child_name from parents a, children b
2* where a.person_id=b.parent_id
SQL> /
ADULT_NAME CHILD_NAME
Dan Anne
Dan Julia
Jack Marcella
SQL>Regards,
Avinash -
Diff bw complex join and physical join
hi all
Can sumbody explain me the all the differences between complex join and physical join in the admin tool
Thanks
ShobhitHi,
Suggest you to go through this link. It may be helpful in detail.
http://st-urriculum.oracle.com/obe/fmw/bi/biee/r1013/bi_admin/biadmin.html
Thanks,
Vengatesh. -
Sample code and senarios to use outer join?
We know the ABAP4 syntax for inner join, but never tried outer join and we even don't know if there is any outer join syntax in ABAP4 or not. Would be very appreciated if some ABAP expert here let us know if there is any outer join and list the difference between inner join and outer join with detailed senarios or when we would use outer join or when to use inner join? Also give a sample code on the outer join if there is any in ABAP?
Thanks and we will give you reward points!Hye..
Left outer join between table 1 and table 2 where column D in both tables set the join condition:
Table 1 Table 2
A
B
C
D
D
E
F
G
H
a1
b1
c1
1
1
e1
f1
g1
h1
a2
b2
c2
1
3
e2
f2
g2
h2
a3
b3
c3
2
4
e3
f3
g3
h3
a4
b4
c4
3
|--|||--|
Left Outer Join
|--||||||||--|
| A | B | C | D | D | E | F | G | H |
|--||||||||--|
| a1 | b1 | c1 | 1 | 1 | e1 | f1 | g1 | h1 |
| a2 | b2 | c2 | 1 | 1 | e1 | f1 | g1 | h1 |
| a3 | b3 | c3 | 2 |NULL|NULL|NULL|NULL|NULL|
| a4 | b4 | c4 | 3 | 3 | e2 | f2 | g2 | h2 |
|--||||||||--|
Example
Output a list of all custimers with their bookings for October 15th, 2001:
DATA: CUSTOMER TYPE SCUSTOM,
BOOKING TYPE SBOOK.
SELECT SCUSTOMNAME SCUSTOMPOSTCODE SCUSTOM~CITY
SBOOKFLDATE SBOOKCARRID SBOOKCONNID SBOOKBOOKID
INTO (CUSTOMER-NAME, CUSTOMER-POSTCODE, CUSTOMER-CITY,
BOOKING-FLDATE, BOOKING-CARRID, BOOKING-CONNID,
BOOKING-BOOKID)
FROM SCUSTOM LEFT OUTER JOIN SBOOK
ON SCUSTOMID = SBOOKCUSTOMID AND
SBOOK~FLDATE = '20011015'
ORDER BY SCUSTOMNAME SBOOKFLDATE.
WRITE: / CUSTOMER-NAME, CUSTOMER-POSTCODE, CUSTOMER-CITY,
BOOKING-FLDATE, BOOKING-CARRID, BOOKING-CONNID,
BOOKING-BOOKID.
ENDSELECT.
Reward if helpful.
Thanks.
Imran. -
When to use IN Queue and When to use OUT Queue
The architecture that we have is Client publishes the EDI 272 data to FTPS Server. We have ESB configured to pick the EDI data from FTP location, construct the B2B Header message and send to B2B. The B2B translates the EDI raw data to EDI XML. BPEL reads the EDI XML data from B2B. I have doubt here in using the IP_IN_QUEUE and IP_OUT_QUEUE. As per my understanding, IP_IN_QUEUE is used for messages inbound to B2B and IP_OUT_QUEUE is used for messages going out of B2B. If this is correct, ESB module would publish to IP_IN_QUEUE and BPEL would pick from IP_OUT_QUEUE.
I'm confused here because I read few examples in which the queues were used other way around.
Kindly clarify whether the usage of IN and OUT queus are correct.
Thanks,
ManiHI Mani,
When B2B receives an inbound message from trading partner, it will send to IP_IN_QUEUE.
When Back application wants to send a message to B2B, Backend application has to send the message to IP_OUT_QUEUE. B2B picks up the message from IP_OUT_QUEUE and send it to trading partner.
The above mentioned queues are shipped with the product. However, users can can create there own queues.
Thanks and Reagrds,
Prasanna -
What is the different between Logical complex join and Physical join?
hi,
Do somebody know what is the function different between logical complex join in BMM layer and physical join in physical layer?
Thanks.Thank you very much1
I understand their differentiation:
In the BMM Complex join (intelligent), means OBI picks the best way from possibly many different ways to join using physical join. FK join forces the same join always, which limits flexibility. -
Hi
I would like to know if there is difference between bind join end hash join.
For example If I write sql code in My query tool (in Data Federator Query server administrator XI 3.0) it is traduced in a hashjoin(....);If I set system parameters in right way to produce bind join, hashjoin(...) is present again!
how do i understand the difference?
byeQuery to track the holder and waiter info
People who reach this place for a similar problem can use the above link to find their answer
Regards,
Vishal -
Performance considerations between a cross join and inner join
Hi there,
What's the performance difference and impact on running a cross-join based query against an inner join based query?
Regards and thanksBefore going to the performance issue - ensure you get the required data and not just some data shown.
Performance should be checked only between equivalent queries which produce same output but with different processing.
Are you sure you get same output in cross join as well as inner join?
If so pass on your different queries and then discuss with one is better. -
Difference between Innner Join and Cross Join
Dear all,
select * from tbl1 inner join tbl2 on tbl1.id =tbl2.id
select * from tbl1 cross join tbl2
Works same what is the logical difference between this two statements??
Dilip Patil..INNER Join returns the rows from both tables which has satisfied matching condition.
In
CROSS Join, each record from tbl1 is matched with tbl2. Result would be Number Of rows in tbl1 X Number of rows in tbl2.
Note: If you provide where condition in CROSS JOIN, it will give you same result as your first INNER JOIN query
select * from tbl1 cross join tbl2
where tbl1.id =tbl2.id
-Vaibhav Chaudhari -
Difference between merge-Not matched and left outer join
Why should Merge-Not Matched be used instead of left outer join? I believe both will enable comparison of 2 tables. So what is the difference. Please advice.
mayooran99MERGE is way to encapsulate all conditions within single statement
The equivalent implementation using join would require three different statements
1 UPDATE using INNER JOIN
1 INSERT using LEFT JOIN
and 1 DELETE using LEFT JOIN in reverse order
Both approaches work fine
so all that you need to do is left join operation to find difference you can use either
But MERGE has one additional advantage in case you need to get output from MERGE and use it for further manipulation like further insert to child table
I've explained it here
http://visakhm.blogspot.in/2014/09/t-sql-tips-multifaceted-merge-statement.html
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
My Wiki User Page
My MSDN Page
My Personal Blog
My Facebook Page -
SAP QUERY/INFOSET with OUTER JOIN
Hi,
I have created an infoset (SQ02) using two tables for SAP query.
Table: AGR_TEXTS. Fields: AGR_NAME, SPRAS, LINE, TEXT.
TABLE: AGR_FLAGS. Fields: AGR_NAME, FLAG_TYPE, FLAG_VALUE.
Joined these two tables using outer join. Defined the join condition as AGR_NAME = AGR_NAME. Saved and Generated the infoset.
Created SAP Query (SQ01) using the above created infoset.
In the basic list,
Marked AGR_NAME (AGR_TEXTS), TEXT, FLAG_VALUE as listed fields.
Marked AGR_NAME (AGR_TEXTS), SPRAS, LINE, FLAG_TYPE as selection fields.
Save the query. When execute the query provided the inputs for all the selection fields in the selection screen as given below:
AGR_NAME=Z*
SPRAS=E
LINE=00000
FLAG_TYPE=LICENSE_01
Executed the Query.
Got the results only the matched records as per the selection field FLAG_TYPE.
But I want all the records from table AGR_TEXTS and matched records from table AGR_FLAGS.
I want the report (output) as below,
_AGR_NAME TEXT FLAG_VALUE_
ZCA_BASIC_ACCESS_GLOBAL Non-critical basic access for all users. 53
ZCA_BASIC_ENDUSER_ACCESS UK:CA Basic Enduser Access
ZCA_BASIC_ENDUSER_ACCESS_UK UK:CA Basic Enduser Access UK 52
ZCA_BASIC_ENDUSER_SU52_UK UK:CA Basic Enduser Access to change Parameter ID's
But I got the report (output) as below,
_AGR_NAME TEXT FLAG_VALUE_
ZCA_BASIC_ACCESS_GLOBAL Non-critical basic access for all users. 53
ZCA_BASIC_ENDUSER_ACCESS_UK UK:CA Basic Enduser Access UK 52
Apprecited your help. Thanks.
Code Formatted by: Alvaro Tejada Galindo on Dec 30, 2009 2:20 PMIdentify a KF for which there are non-zero values for all accounts in the cube.
Create the query with Account (from MP coming from both IO and cube) and this KF. KF will have 0 values for accounts not existing in the cube. Create a condition to show only the 0 value for the KF. This should show you all the accounts in the IO which are not in the cube.
Maybe you are looking for
-
Is there a way for me to set up an event in iCal (in this case, a project deadline), with rules, and have iCal automatically set up reminders for different aspects of the project up to 8 weeks before the deadline? I would need fixed reminders, such a
-
Mail receiver adapter - line feed problem
Hi! I am just configuring a mail receiver adapter. In the module tab i configured a conversion from XML to plain which works well. The plain text file is created but there are no line feeds after the plain text lines. The configuration in the module
-
Installing Application Server 10g (10.1.3) on Windows Server 2008 Document
Basically, I need to find out if 10.1.3 application server Enterprise Edition can be installed on Windows Server 2008 with a 64-bit operating system. A yes or no is helpful, but I would like to have a link to the documentation. I'm assisting on an in
-
Working w/ Mav (10.9.1) I ran into a curious Finder problem: after performing a file search in a Finder window (search box top right) I got a list of files with no icons in front of the file names and none of the items shown is clickable (see screens
-
Including a jsp page onto other jsp
Could any one tell me how to include a jsp on other jsp For ex: including header.jsp and footer.jsp on all pages of application. Thanks