Diff "full outer join" is going. "(+)" SELECT syntax?
As far as I know there are two ways to set an outer join:Select... from tab1 external t1 full join tab2 t2 on t1.id = t2.id;
or:
SELECT... from tab1 tab2 t2, t1 where t1.id = t2.id (+)
They are absolutely equivialent?
Who are the most common one?
Who serve as well on other databases (DB2, MySQL)?
Can I put an additional WHERE clause at the end of the first statement:
SELECT... from tab1 t1 outer join t2 on t1.id = t2.id tab2 complete WHOSE...;
Select... from tab1 external t1 full join tab2 t2 on t1.id = t2.id;
It's FULL OUTER JOIN
SELECT... from tab1 tab2 t2, t1 where t1.id = t2.id (+)
It's LEFT OUTER JOIN.
They are quite different.
FULL OUTER JOIN - retrieves all the rows from tab1 and tab2
LEFT OUTER JOIN - gets all the tab1 and lines than the line that matches the join condition of tab2.
Here is a simple test.
create table tab1(id integer)
/
create table tab2(id integer)
/
begin
insert into tab1 values(1);
insert into tab1 values(2);
insert into tab1 values(3);
end;
/
begin
insert into tab2 values(3);
insert into tab2 values(4);
insert into tab2 values(5);
end;
/
Select t1.id, t2.id
from tab1 t1 full outer join tab2 t2
on t1.id =t2.id
/
Select t1.id, t2.id
from tab1 t1, tab2 t2
where t1.id = t2.id(+)
/
Run it and see the result.
Tags: Database
Similar Questions
-
HELP SQL (auto / full outer join with date corresponding)
I'm having a hard time get this query nailed... hoping someone can help me sorted.
create table tab1 (identification number,
date of eff_date,
Code1 varchar2 (2),
Code2 varchar2 (2)
)
/
insert into tab1 values (2, to_date('2015-01-14','YYYY-MM-DD'), 'DAT', 'AS');
insert into tab1 values (2, to_date('2015-03-19','YYYY-MM-DD'), 'DAT', 'AS');
insert into tab1 values (2, to_date('2015-08-28','YYYY-MM-DD'), 'DAT', 'AS');
insert into tab1 values (2, to_date('2015-11-12','YYYY-MM-DD'), 'DAT', 'AS');
insert into tab1 values (2, to_date('2015-01-03','YYYY-MM-DD'), "DAT", "AE");
insert into tab1 values (2, to_date('2015-03-14','YYYY-MM-DD'), "DAT", "AE");
insert into tab1 values (2, to_date('2015-04-18','YYYY-MM-DD'), "DAT", "AE");
insert into tab1 values (2, to_date('2015-09-14','YYYY-MM-DD'), "DAT", "AE");
insert into tab1 values (2, to_date('2015-01-14','YYYY-MM-DD'), "DAT", "BS");
insert into tab1 values (2, to_date('2015-02-14','YYYY-MM-DD'), "DAT", "BS");
insert into tab1 values (2, to_date('2015-03-14','YYYY-MM-DD'), "DAT", "BS");
insert into tab1 values (2, to_date('2015-05-14','YYYY-MM-DD'), 'DAT', 'BE');
insert into tab1 values (3, to_date('2015-09-16','YYYY-MM-DD'), 'DAT', 'AS');
insert into tab1 values (3, to_date('2015-04-16','YYYY-MM-DD'), "DAT", "AE");
tab1
ID, date, code 1, code2
2. DID DAT 2015-01-14
2. DID DAT 2015-03-19
2. DID DAT 2015-08-28
2. DID DAT 2015-11-12
2 AE DAT 2015-01-03
2 AE DAT 2015-03-14
2 AE DAT 2015-04-18
2 AE DAT 2015-09-14
2 BS DAT 2015-01-14
2 BS DAT 2015-02-14
2 BS DAT 2015-03-14
BE DAT 2 2015-05-14
3. DID DAT 2015-09-16
3 AE DAT 2015-04-16
What I need to do...
1 auto join to match EI for each partition ID
2. THAT the date must be less than or equal to the date of the AE and when there is more then a line corresponding to this criterion has chosen the date of closest EI of the date of the ACE.
3. it must be a full outer join because I want to show all lines, even if it is not a match. There is a beginning, but not record end end gold but no record of departure
4. If there is an AE line for many AS lines (the SA date is less then equals the date of EI) then join this AE line to all 3 rows of ACE
5. the same rules for BS and BE.
result should look like this.
ID, date, code 1, id_1 code2, date_1, code1_1, code2_1
2 2015-01-14 DAT AS 2 AE DAT 2015-03-14
2 2015-03-19 DAT AS 2 AE DAT 2015-04-18
2 2015-08-28 DAT AS 2 AE DAT 2015-09-14
2 2015-11-12 DAT DID ZERO ZERO ZERO ZERO
NO NO NO NO 2 AE DAT 2015-01-03
2015-01-2 14 DAT BS 2 BE DAT 2015-05-14
2015-02-2 14 DAT BS 2 BE DAT 2015-05-14
2015 03-2 14 DAT BS 2 BE DAT 2015-05-14
3 2015-09-16 DAT DID ZERO ZERO ZERO ZERO
NO NO NO NO 3 AE DAT 2015-04-16
My attempt was somewhat along these lines (dealing only with SA / combos AE) but it does not manage the many scenarios one (req 4).
Select a.*, b.* from
(select row_number () on the rn (partition by a.id order a.eff_date), a.*)
of tab1 where a.code2 = 'AS') a
full outer join
(select row_number () on the rn (b.eff_date order by b.id partition), b.*)
tab1 b where b.code2 = 'Æ') b
on a.id = b.id
and a.rn = b.rn
and a.eff_date < = b.eff_date
Hello
owbdev99 wrote:
I'm having a hard time get this query nailed... hoping someone can help me sorted.
create table tab1 (identification number,
date of eff_date,
Code1 varchar2 (2),
Code2 varchar2 (2)
)
/
insert into tab1 values (2, to_date('2015-01-14','YYYY-MM-DD'), 'DAT', 'AS');
...
Thanks for posting the CREATE TABLE and INSERT. I know it can be a lot of trouble. You want to get answers that work, not you? Make sure that the statements you post too much work. Test (and, if necessary, attach) your statements before committing. You said code1 be VARCHAR2, but all the instructions insertion have values of 3 characters for code1.
You are on the right track, with an analytical function, but ROW_NUMBER solves this problem. 1 "THAT line" could correspond to the 1st, 2nd, 3rd or any other line 'AE' and vice versa. Try to use the analytical MIN function instead or ROW_NUMBER, like this:
WITH got_next_e_date AS
(
SELECT id, eff_date, code1, code2
MIN (CASE
WHEN SUBSTR (code2, 2) = 'E '.
THEN eff_date
END
) OVER (PARTITION BY ID.
, SUBSTR (code2, 1, 1)
ORDER BY eff_date DESC
) AS next_e_date
OF tab1
)
s AS
(
SELECT *.
OF got_next_e_date
"WHERE SUBSTR (code2, 2) s ="
)
e
(
SELECT *.
OF got_next_e_date
WHERE SUBSTR (code2, 2) = 'E '.
)
SELECT s.id
s.eff_date
s.code1
s.code2
e.id AS id_1
e.eff_date AS eff_date_1
e.code1 AS code1_1
e.code2 AS code2_1
S
FULL OUTER JOIN e ON s.id = e.id
AND s.next_e_date = e.eff_date
AND SUBSTR (s.code2, 1, 1) = SUBSTR (e.code2, 1, 1)
ORDER OF NVL (s.id, e.id)
, NVL (SUBSTR (s.code2, 1, 1)
, SUBSTR (e.code2, 1, 1)
)
s.eff_date
;
Out (as you asked):
ID EFF_DATE CODE1, CODE2 ID_1 EFF_DATE_1 CODE1_1 CODE2_1
--- ---------- ----- ----- ----- ---------- ------- -------
2 2015-01-14 DAT AS 2 AE DAT 2015-03-14
2 2015-03-19 DAT AS 2 AE DAT 2015-04-18
2 2015-08-28 DAT AS 2 AE DAT 2015-09-14
2. DID DAT 2015-11-12
2 AE DAT 2015-01-03
2015-01-2 14 DAT BS 2 BE DAT 2015-05-14
2015-02-2 14 DAT BS 2 BE DAT 2015-05-14
2015 03-2 14 DAT BS 2 BE DAT 2015-05-14
3. DID DAT 2015-09-16
3 AE DAT 2015-04-16
I guess code2 is always 2 characters, and the 2nd character is always ' or 'E '.
I assume that the combination [id, eff_date, code2] is unique.
If these assumptions are wrong, you need a few minor changes, but nothing big.
-
30%
Hello
I have a few questions to ask. Please see below I have provided a script to recreate my problem.
Question 1.
I have the following query does not work when I include columns (see 1.2) in the select but will run when I use the Asterix symbol (see 1.1)
* 1.1 runs with no problems *.
* 1.2 returns error.*select * from ora full outer join txt on ora.ora_id_y = txt.txt_id_y;
Question 2.select txt.txt_id_y , txt.txt_n , txt.txt_y , ora.ora_n , ora.ora_y from ora full outer join txt on ora.ora_id_y = txt.txt_id_y; Error report: SQL Error: ORA-00918: column ambiguously defined 00918. 00000 - "column ambiguously defined" *Cause: *Action:
Is it possible to use a query with joins free and using multiple outer joins to accomplish what I have under which is seen 6 to access the query I have to Question 1.
CREATE THE SCRIPT
Published by: benton on August 21, 2012 10:48drop table master; create table master ( id varchar2 (10 char) , txt varchar2 (1 char) , ora varchar2 (1 char) ); INSERT INTO MASTER (ID, TXT, ORA) VALUES ('orange' , 'Y', 'Y'); INSERT INTO MASTER (ID, TXT, ORA) VALUES ('apple', 'Y', ''); INSERT INTO MASTER (ID, TXT, ORA) VALUES ('orange' , 'Y', 'N'); INSERT INTO MASTER (ID, TXT, ORA) VALUES ('peach' , 'Y', ''); create or replace force view ora_n as select id , count (ora) ORA_N from master where ora in ('N') group by id; create or replace force view ora_y as select id , count (ora) ORA_Y from master where ora in ('Y') group by id; create or replace force view txt_n as select id , count (txt) TXT_N from master where txt in ('N') group by id; create or replace force view txt_y as select id , count (txt) TXT_Y from master where txt in ('Y') group by id; create or replace force view ora as select ora_n.id ora_id_n , ora_y.id ora_id_y , ora_n.ora_n , ora_y.ora_y from ora_n full outer join ora_y on ora_n.id = ora_y.id; create or replace force view txt as select txt_y.id txt_id_n , txt_y.id txt_id_y , txt_n.txt_n , txt_y.txt_y from txt_n full outer join txt_y on txt_n.id = txt_y.id;
Published by: benton on August 21, 2012 11:11Found: support for Oracle, there are:
Bug 6319169 : ORA-918, FULL OUTER JOIN
Reproduced on 10.2.0.1,10.2.0.3.
Fixed to the product Version 11.0
WORKAROUND solution: alter session set '_column_elimination_off' = true; -
What is the Assembly of 4 or 5 tables FULL OUTER JOIN logic?
the query is as below:
as you can see, I need FULL OUTER JOIN, these 5 tables and get a column from each table that is based on three common columns (ORG_iD, CUST_ID, CURRENT_DT).
And I wonder what is the logic of the 5 FULL OUTER JOIN table?
It will return if there is a folder that exists in the single table COL1? or table, COL2 and COL3 and so on. Basically any combination of these 5 tables.
Any ideas?SELECT (CASE WHEN COL1.ORG_ID IS NOT NULL THEN COL1.ORG_ID WHEN COL2.ORG_ID IS NOT NULL THEN COL2.ORG_ID WHEN COL3.ORG_ID IS NOT NULL THEN COL3.ORG_ID WHEN COL4.ORG_ID IS NOT NULL THEN COL4.ORG_ID ELSE COL5.ORG_ID END) ORG_ID, (CASE WHEN COL1.CUST_ID IS NOT NULL THEN COL1.CUST_ID WHEN COL2.CUST_ID IS NOT NULL THEN COL2.CUST_ID WHEN COL3.CUST_ID IS NOT NULL THEN COL3.CUST_ID WHEN COL4.CUST_ID IS NOT NULL THEN COL4.CUST_ID ELSE COL5.CUST_ID END) CUST_ID, (CASE WHEN COL1.CURRENT_DT IS NOT NULL THEN COL1.CURRENT_DT WHEN COL2.CURRENT_DT IS NOT NULL THEN COL2.CURRENT_DT WHEN COL3.CURRENT_DT IS NOT NULL THEN COL3.CURRENT_DT WHEN COL4.CURRENT_DT IS NOT NULL THEN COL4.CURRENT_DT ELSE COL5.CURRENT_DT END) CURRENT_DT, 'VENDORS' as ITEM_NAME, V_AGE_IND as ACCT_AGE_IND, COL1.AMT_ZSHT, COL2.AMT_YFYS, COL3.AMT_YFYS, COL4.AMT_YFYS, COL5.AMT_BZL, 'NAV', sysdate FROM COL1 FULL OUTER JOIN COL2 ON (COL1.ORG_ID=COL2.ORG_ID AND COL1.CURRENT_DT=COL2.CURRENT_DT AND COL1.CUST_ID=COL2.CUST_ID) FULL OUTER JOIN COL3 ON (COL2.ORG_ID=COL3.ORG_ID AND COL2.CURRENT_DT=COL3.CURRENT_DT AND COL2.CUST_ID=COL3.CUST_ID) FULL OUTER JOIN COL4 ON (COL3.ORG_ID=COL4.ORG_ID AND COL3.CURRENT_DT=COL4.CURRENT_DT AND COL3.CUST_ID=COL4.CUST_ID) FULL OUTER JOIN COL5 ON (COL4.ORG_ID=COL5.ORG_ID AND COL4.CURRENT_DT=COL5.CURRENT_DT AND COL4.CUST_ID=COL5.CUST_ID)
Thank youHello
When you perform a JOIN EXTERNAL COMPLETE multi - build that way, whenever you add a new table, you can just join the previous table because this table could be all NULL values for a given row. You can reach each new table to the first table, either, for the same reason. You must enclose each new table with all previous tables, like this:
FULL OUTER JOIN COL2 ON COL2.ORG_ID = COL1.ORG_ID AND COL2.CURRENT_DT = COL1.CURRENT_DT AND COL2.CUST_ID = COL1.CUST_ID FULL OUTER JOIN COL3 ON COL3.ORG_ID = COLAESCE (COL1.ORG_ID, COL2.ORG_ID) AND COL3.CURRENT_DT = COALESCE (COL1.CURRENT_DT, COL2.CURRENT_DT) AND COL3.CUST_ID = COALESCE (COL1.CUST_ID, COL2.CUST_ID) FULL OUTER JOIN COL3 ON COL4.ORG_ID = COLAESCE (COL1.ORG_ID, COL2.ORG_ID, COL3.ORG_ID) AND COL4.CURRENT_DT = COALESCE (COL1.CURRENT_DT, COL2.CURRENT_DT, COL3.CURRENT_DT) AND COL4.CUST_ID = COALESCE (COL1.CUST_ID, COL2.CUST_ID, COL3.CUST_ID) FULL OUTER JOIN COL3 ON COL5.ORG_ID = COLAESCE (COL1.ORG_ID, COL2.ORG_ID, COL3.ORG_ID, COL4.ORG_ID) AND COL5.CURRENT_DT = COALESCE (COL1.CURRENT_DT, COL2.CURRENT_DT, COL3.CURRENT_DT, COL4.CURRENT_DT) AND COL5.CUST_ID = COALESCE (COL1.CUST_ID, COL2.CUST_ID, COL3.CUST_ID, COL4.CUST_ID)
I hope that answers your question.
If not, post a small example data (CREATE TABLE and only relevant columns, INSERT statements), and the results you want from this data.
Explain how you get these results from these data.
Always tell what version of Oracle you are using. -
Help required in a full outer join
In my view, the query below can be changed at the full outer join. But, I was not able to do.
I need your help to change to the full outer join. My current request isSELECT CLAIMNO,'1' INDX FROM D_CLAIM@CMS2PROD WHERE clntsys=76500 and facility=76501 and filecreatedt='18-feb-2011' and fileupdatedt is null MINUS SELECT CLAIMNO,'1' FROM D_CLAIM WHERE clntsys=76500 and facility=76501 and filecreatedt='18-feb-2011' and fileupdatedt is null UNION SELECT CLAIMNO,'2' FROM D_CLAIM WHERE clntsys=76500 and facility=76501 and filecreatedt='18-feb-2011' and fileupdatedt is null MINUS SELECT CLAIMNO,'2' FROM D_CLAIM@cms2prod WHERE clntsys=76500 and facility=76501 and filecreatedt='18-feb-2011' and fileupdatedt is null
Something like:
select nvl(p.claimno,s.claimno) claimno, nvl2(p.claimno,'PROD','STAGING') the_source, :the_clntsys clntsys, :the_facility facility from (select claimno from d_claim where clntsys = :the_clntsys and facility = :the_facility ) p full outer join (select claimno from d_claim@cms2prod /* never tried with remote */ where clntsys = :the_clntsys and facility = :the_facility ) s on p.claimno = s.claimno where p.claimno is null or s.claimno is null
Concerning
Etbin
-
Hi all
I need assistance with SQL FULL OUTER JOIN.
How to write with FULL OUTER JOIN, the query.
I tried like
I have 3 different queries.
Query q: SELECT emp_id LN.emp_id.
Sum (LN_amount) loan_amt
MY_LON_TAB LN
WHERE LN_amount > 20000
LN.emp_id GROUP;
Query b: SELECT PLN. EMP_ID emp_id,
Sum (PLAN_AMOUNT) plan_amt
FROM PLN MY_PLAN_TAB
where PLAN_AMOUNT <>0
GROUP BY PLN. EMP_ID;
Query C:
SELECT FLX. EMP_ID emp_id,
SUM (PRORATE_AMOUNT) PRORATE_AMT
OF MY_FLX_TAB FLX
WHERE PRORATE_AMOUNT <>0
FLX GROUP. EMP_ID;
Suppose that the different subquery above 3 a, b, c respectively. each subquery with emp_id and respective amount.
like a.emp_id, a.loan_amt
b.emp_id, b.plan_amt
c.emp_id, c.prorate_amt
I show all the empid with their amount respective.
schenario: If an account made, but not vice-versa b
and B have record, but not vice versa c
and a credit record but not vice versa c
first: I have external is associated with the A and B
Second: join external then complete the total outcome of (a & b) with c
but empid c just as empty.
My output is:
emp_id a.loan_amt, b.plan_amt c.prorate_amt
101 5000 null null
102 4500 null 2000
103 6700 null null
How to solve the foregoing to the ANSI (FULL OUTER JOIN) method.
Please suggest me.
Thanks in advance...
PKMHello
It is very difficult for anyone to say what you're doing wrong if they do not know what you are doing. Post your code FULL OUTER JOIN.
My best guess is:WITH a AS ( SELECT ... -- What you posted as query a ) , b AS ( SELECT ... -- What you posted as query b ) , c AS ( SELECT ... -- What you posted as query c ) SELECT COALESCE ( a.emp_id , b.emp_id , c.emp_id ) AS emp_id , ... -- whatever other columns you want FROM a FULL OUTER JOIN b ON b.emp_id = a.emp_id FULL OUTER JOIN c ON c.emp_id = COALESCE (a.emp_id, b.emp_id) ;
I hope that answers your question.
If not, post a small example (CREATE TABLE and INSERT statements) data for all tables and the results expected from these data (if not what you have already posted). -
[8i] need help with full outer join combined with a cross join...
I can't understand how to combine a full outer join with a different type of join... is it possible?
Here are some create table and insert for examples of database:
And, the results that I want to get: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);
I tried a number of different things, google my problem and no luck yet...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 4
So, what I want, it's a full outer join of t1 and t2 on workstation and a cross join of one with the t3. I wonder if I can't find examples of it online because it is not possible...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 ...
Note: I'm stuck dealing with Oracle 8i
Thank you!!Hello
The query I posted yesterday is a little more complex that it should be.
My_tab2.workstation is unique, there is no reason to make a separate subquery as mt1. We can join my_tab1 to my_tab2 and get the SUM in a subquery.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, and very clear expected results!
user11033437 wrote:
... So, what I want, it's a full outer join of t1 and t2 on workstation and a cross join of one with the t3.She, exactly!
The trickiest part is when and how get SUM (my_value). You could address the question of exactly what my_tab3 must be attached to a cross that's exactly what should look like the result set of the full outer join between my_tab1 and my_tab2 to. To do this, take your desired results, remove columns that do not come from the outer join complete and delete duplicate rows. You will get:workstation sum(my_value) wkstn_name ----------- ------------- ---------- ABCD 30 WKSTN 1 A123 35 WKSTN 2 B456 0 WKSTN 3 ???? 5 NULL
So the heart of the problem is how to get these results of my_tab1 and my_tab2, which is done in the subquery FOJ above.
I tried to use auto-documenté in my code names. I hope you can understand.
I could spend hours explaining the different parts of this query more in detail, but I don't know that I would lose some of that time, explain things that you already understand. If you want an explanation of the specific element (s), let me know. -
full outer join: how to get without null values?
full outer join: how to get without null values?Hello
Please go well this url
http://asktom.Oracle.com/pls/asktom/f?p=100:11:999478429860455:P11_QUESTION_ID:6585774577187
Thank you
Prakash P -
Hi guys,.
I use Oracle 10 G database. When I run the query below, I am of course a mistake given that an outer join more then one table:
---------------------
---------------------SELECT MV_VAA_INC_MONTHLY_SUMMARY.Month_ID, MV_VAA_INC_MONTHLY_SUMMARY.PRIORITY, sum(MV_VAA_INC_MONTHLY_SUMMARY.CLOSED), decode(MV_VAA_INC_MONTHLY_SUMMARY.SLA_MET, 1, 0, 1), MV_VAA_INC_MONTHLY_SUMMARY.INCIDENT_NUMBER, to_char(MV_VAA_INC_MONTHLY_SUMMARY.FIRST_DAY_OF_THE_MONTH, 'Mon')||' '||to_char(MV_VAA_INC_MONTHLY_SUMMARY.FIRST_DAY_OF_THE_MONTH, 'yy'), INC_BREACH_SLA_DETAILS.RESPONSIBILITY FROM MV_VAA_INC_MONTHLY_SUMMARY , HPD_HELP_DESK, INC_BREACH_SLA_DETAILS, MIS_QUEUES_RESP INC_MIS_QUEUES_RESP WHERE ( ( INC_MIS_QUEUES_RESP.RESP = ANY ('TCS', 'NONTCS') ) AND ( ( MV_VAA_INC_MONTHLY_SUMMARY.FIRST_DAY_OF_THE_MONTH ) BETWEEN ( add_months(trunc(sysdate,'MM'), -4) ) AND ( trunc(sysdate,'MM') -1 ) ) AND MV_VAA_INC_MONTHLY_SUMMARY.Month_ID = 201110 AND MV_VAA_INC_MONTHLY_SUMMARY.INCIDENT_NUMBER (+) = HPD_HELP_DESK.INCIDENT_NUMBER AND INC_BREACH_SLA_DETAILS.INCIDENT_NUMBER=HPD_HELP_DESK.INCIDENT_NUMBER (+) AND INC_MIS_QUEUES_RESP.SUPPORT_GROUP_ID=HPD_HELP_DESK.ASSIGNED_GROUP_ID (+) ) GROUP BY MV_VAA_INC_MONTHLY_SUMMARY.Month_ID, MV_VAA_INC_MONTHLY_SUMMARY.PRIORITY, decode(MV_VAA_INC_MONTHLY_SUMMARY.SLA_MET, 1, 0, 1), MV_VAA_INC_MONTHLY_SUMMARY.INCIDENT_NUMBER, to_char(MV_VAA_INC_MONTHLY_SUMMARY.FIRST_DAY_OF_THE_MONTH, 'Mon')||' '||to_char(MV_VAA_INC_MONTHLY_SUMMARY.FIRST_DAY_OF_THE_MONTH, 'yy'), INC_BREACH_SLA_DETAILS.RESPONSIBILITY HAVING sum(MV_VAA_INC_MONTHLY_SUMMARY.CLOSED) = 1
But when I run the sub query quite similar, I do not receive an error.
-------------------------
-------------------------SELECT MV_VAA_INC_MONTHLY_SUMMARY.Month_ID, MV_VAA_INC_MONTHLY_SUMMARY.PRIORITY, sum(MV_VAA_INC_MONTHLY_SUMMARY.CLOSED), decode(MV_VAA_INC_MONTHLY_SUMMARY.SLA_MET, 1, 0, 1), MV_VAA_INC_MONTHLY_SUMMARY.INCIDENT_NUMBER, to_char(MV_VAA_INC_MONTHLY_SUMMARY.FIRST_DAY_OF_THE_MONTH, 'Mon')||' '||to_char(MV_VAA_INC_MONTHLY_SUMMARY.FIRST_DAY_OF_THE_MONTH, 'yy'), INC_BREACH_SLA_DETAILS.RESPONSIBILITY FROM MV_VAA_INC_MONTHLY_SUMMARY RIGHT OUTER JOIN HPD_HELP_DESK ON (MV_VAA_INC_MONTHLY_SUMMARY.INCIDENT_NUMBER=HPD_HELP_DESK.INCIDENT_NUMBER) LEFT OUTER JOIN INC_BREACH_SLA_DETAILS ON (INC_BREACH_SLA_DETAILS.INCIDENT_NUMBER=HPD_HELP_DESK.INCIDENT_NUMBER) LEFT OUTER JOIN MIS_QUEUES_RESP INC_MIS_QUEUES_RESP ON (INC_MIS_QUEUES_RESP.SUPPORT_GROUP_ID=HPD_HELP_DESK.ASSIGNED_GROUP_ID) WHERE ( ( INC_MIS_QUEUES_RESP.RESP = ANY ('TCS', 'NONTCS') ) AND ( ( MV_VAA_INC_MONTHLY_SUMMARY.FIRST_DAY_OF_THE_MONTH ) BETWEEN ( add_months(trunc(sysdate,'MM'), -4) ) AND ( trunc(sysdate,'MM') -1 ) ) AND INC_BREACH_SLA_DETAILS.RESPONSIBILITY NOT IN ( 'NONE' ) AND MV_VAA_INC_MONTHLY_SUMMARY.Month_ID = 201110 ) GROUP BY MV_VAA_INC_MONTHLY_SUMMARY.Month_ID, MV_VAA_INC_MONTHLY_SUMMARY.PRIORITY, decode(MV_VAA_INC_MONTHLY_SUMMARY.SLA_MET, 1, 0, 1), MV_VAA_INC_MONTHLY_SUMMARY.INCIDENT_NUMBER, to_char(MV_VAA_INC_MONTHLY_SUMMARY.FIRST_DAY_OF_THE_MONTH, 'Mon')||' '||to_char(MV_VAA_INC_MONTHLY_SUMMARY.FIRST_DAY_OF_THE_MONTH, 'yy'), INC_BREACH_SLA_DETAILS.RESPONSIBILITY HAVING sum(MV_VAA_INC_MONTHLY_SUMMARY.CLOSED) = 1
Please can you advise the reason.
See you soon,.
Khadi
Published by: BluShadow on November 11, 2011 10:54
addition of {noformat}{noformat} tags. Please read {message:id=9360002} and learn to do this yourself.
Hi, yaya,
888121 wrote:
Hi guys,.In fact I'm not guru in Oracle as such. The first query, I pasted works well.
You mean the second query (one with ANSI joins) is running fine and the first query (with signs +) is a mistake, right?
Looking at this request I created the joins in the second, but then I get this error. I just want to understand what is the difference in the ANSI query and mine is throwing this error.
Join ANSI rating supports outer joins to more than one table; the old syntax doesn't work. That's all there is to it. The ANSI syntax also supports FULL OUTER JOIN, and the old syntax does not work. There is nothing wrong with more than one table outer join, just as there is nothing wrong with a full outer join. You can do it with the old syntax, but just more coding.
Published by: Frank Kulash, November 11, 2011 08:16
-
Bug in outer join syntax?
I use Oracle 10.2, and I think I found a bug in what is allowed for the outer join syntax. Specifically, I am allowed to specify "outer join" without specifying if it's left, right, or full outer join. It behaves as an inner join.
The documents show that the type_de_jointure is optional, but does not allow the 'outside' keyword be used alone: http://download.oracle.com/docs/cd/A97630_01/server.920/a96540/statements_103a.htm#2126207
Small example:
The release of the last three selects shows that the OUTER JOIN behaves as a simple JOIN, rather than return a syntax error or at least behave like a FULL OUTER JOIN (this is where the absence of a syntax error is misleading):create table TABLE_A (ID number(10) primary key, VALUE_A varchar2(50)); create table TABLE_B (ID number(10) primary key, VALUE_B varchar2(50)); insert into TABLE_A (ID, VALUE_A) values (1, 'abc'); insert into TABLE_A (ID, VALUE_A) values (2, 'def'); insert into TABLE_A (ID, VALUE_A) values (3, 'ghi'); insert into TABLE_B (ID, VALUE_B) values (2, 'jkl'); insert into TABLE_B (ID, VALUE_B) values (3, 'mno'); insert into TABLE_B (ID, VALUE_B) values (4, 'pqr'); commit; select ID, VALUE_A from TABLE_A; select ID, VALUE_B from TABLE_B; select ID, VALUE_A, VALUE_B from TABLE_A join TABLE_B using (ID); select ID, VALUE_A, VALUE_B from TABLE_A full outer join TABLE_B using (ID); select ID, VALUE_A, VALUE_B from TABLE_A outer join TABLE_B using (ID);
Y at - there somewhere that I can tell you that?SQL> select ID, VALUE_A, VALUE_B from TABLE_A join TABLE_B using (ID); ID VALUE_A VALUE_B ---------- -------------------------------------------------- -------------------------------------------------- 2 def jkl 3 ghi mno SQL> select ID, VALUE_A, VALUE_B from TABLE_A full outer join TABLE_B using (ID); ID VALUE_A VALUE_B ---------- -------------------------------------------------- -------------------------------------------------- 1 abc 2 def jkl 3 ghi mno 4 pqr SQL> select ID, VALUE_A, VALUE_B from TABLE_A outer join TABLE_B using (ID); ID VALUE_A VALUE_B ---------- -------------------------------------------------- -------------------------------------------------- 2 def jkl 3 ghi mno SQL>
If you have a supported Oracle agreement you can save a Service request with Oracle, but they can answer that this is not a bug. The problem is that the 'outside' keyword in your 3rd example is treated as an alias for TABLE_A because it is not considered as a reserved keyword.
with table_a as ( select 1 as id, 'abc' as value_a from dual union all select 2 as id, 'def' as value_a from dual union all select 3 as id, 'ghi' as value_a from dual ) , table_b as ( select 2 as id, 'jkl' as value_b from dual union all select 3 as id, 'mno' as value_b from dual union all select 4 as id, 'pqr' as value_b from dual ) select ID, outer.VALUE_A, VALUE_B from TABLE_A outer join TABLE_B using (ID); ID VALUE_A VALUE_B ---------------------- ------- ------- 2 def jkl 3 ghi mno
If you query the view RESERVED_WORDS of V$ it will tell you what keywords are reserved.
select * from V$RESERVED_WORDS where keyword in ('OUTER', 'SELECT','USING'); KEYWORD LENGTH RESERVED RES_TYPE RES_ATTR RES_SEMI DUPLICATE ------------------------------ ---------------------- -------- -------- -------- -------- --------- USING 5 N N N N N OUTER 5 N N N N N SELECT 6 Y N N N N
You'll get a similar result, if you tried
select ID, VALUE_A, VALUE_B from TABLE_A using join TABLE_B using (ID);
Kind regards
Bob -
FULLT OUTER JOIN on two different selects
Hello
I am facing a problem where I don't just get the handle to solve.
I have two pieces of music with different return values. This value should be compared and joined. Simply put, I do an example where the return of the selection is represented as the table1 and table2
Here is the example:
comp_nr is the combination of abc_comp_nr or xyz_comp_nrtable1 abc_comp_nr, abc_cnt_emp 12000, 15 12500, 10 13000, 30 13500, 10 table2 xyz_comp_nr, xyz_cnt_emp 12000, 15 13000, 30 14000, 20 Output should be this: comp_nr, abc_cnt_emp, xyz_cnt_emp 12000, 15, 15 12500, 10, 0 13000, 30, 30 13500, 10, 0 14000, 0, 20
I tried this but did not work as expected:
Select?, abc_cnt_emp, xyz_cnt_emp
Of
Table1 FULL OUTER JOIN table2
ON abc_comp_nr = xyz_comp_nr
Hope that someone was in trouble similar and found a good way to work it.
Thanks in advance
TobiasHi, Tobias,.
Tobias Arnhold wrote:
HelloI am facing a problem where I don't just get the handle to solve.
I have two pieces of music with different return values. This value should be compared and joined. Simply put, I do an example where the return of the selection is represented as the table1 and table2
Here is the example:table1 abc_comp_nr, abc_cnt_emp 12000, 15 12500, 10 13000, 30 13500, 10 table2 xyz_comp_nr, xyz_cnt_emp 12000, 15 13000, 30 14000, 20
Whenever you have a problem, post CREATE TABLE and INSERT statements for the sample data.
See the FAQ forum {message identifier: = 9360002}Output should be this: comp_nr, abc_cnt_emp, xyz_cnt_emp 12000, 15, 15 12500, 10, 0 13000, 30, 30 13500, 10, 0 14000, 0, 20
comp_nr is the combination of abc_comp_nr or xyz_comp_nr
I tried this but did not work as expected:
Select?, abc_cnt_emp, xyz_cnt_emp
Of
Table1 FULL OUTER JOIN table2
ON abc_comp_nr = xyz_comp_nrInstead of??? you want to
NVL (abc_comp_nr, xyz_comp_nr)
The first column is supposed to be the common identifier, abc_comp_nr, or xyz_comp_nr. It doesn't matter which, since the join condition
ON abc_comp_nr = xyz_comp_nr
said they will be the same, except that it's a FULL OUTER JOIN, if one of them might be null. If you want to display the non NULL when one of them is NULL and or the other (any) when they are both present. It's just that NVL.
You can use NVL on other columns, too, to display 0 instead of NULL when there is no match:
SELECT NVL ( abc_comp_nr, xyz_comp_nr) AS comp_nr , NVL ( abc_cnt_emp, 0) AS abc_cnt_emp , NVL ( xyz_cnt_emp, 0) AS xyz_cnt_emp FROM table1 FULL OUTER JOIN table2 ON abc_comp_nr = xyz_comp_nr ;
However, this will display 0 instead of NULL for abc_cnt_emp and xyz_cnt_emp when these columns are NULL for a reason, not just at the time when they do not reach the join condition. If the original paintings contain NULL values and you should keep NULL values in the result set, but you want NULLs which were created by the outer join to show as 0, then you may want something like this:
SELECT NVL ( abc_comp_nr, xyz_comp_nr) AS comp_nr , NVL2 ( abc_comp_nr, abc_cnt_emp, 0) AS abc_cnt_emp , NVL2 ( xyz_comp_nr, xyz_cnt_emp, 0) AS xyz_cnt_emp FROM table1 FULL OUTER JOIN table2 ON abc_comp_nr = xyz_comp_nr ;
Whenever you use FULL OUTER JOIN, there is an excellent chance that you will want to use NVL (or his brother younger, stronger, COALESCE, or their cousin NVL2) as well.
Published by: Frank Kulash on 3 March 2013 14:49
-
Hello
I have a requirement in which I need to get data from a third table where a date of the third table is higher than a date in the second array.
Ex:
SELECT t1.column1, t3.column2 FROM t1, t2, t3 WHERE t1.id = t2.foreign_id AND t1.id ( + ) = t3.foreign_id AND t3.some_date_column > t2.another_date_column
However, using the query above returns no results if the date condition is not met. I still need to show t1.column1 and a null t3.column2.
How should I do this?
Thank you
Allen
Edit: Added information about the requirement.
Hi Allen
- SELECT t1.column1, t3.column2
- T1, t2, t3
- WHERE t1.id = t2.foreign_id
- AND t1.id = t3.foreign_id (+)
- AND t3.some_date_column (+) > t2.another_date_column
I guess that this t1.column1 must not be null. Or am I wrong? The + sign must be placed on the side where draws are accepted. You must repeat it for each condition on the table.
Alternativlely you can use the LEFT OUT JOIN syntax. If the two columns are allowed null you need a FULL OUTER JOIN.
BTW: The join to t2 is not required if a refefernce constraint forced.
-
Performance of outer join problem
Dear all,
Please help me in the development the sub query as it is particularly the outer join and goes for full scan of the table.
Query:
SELECT
T27. CONFLICT_ID,
T27. LAST_UPD,
T27. CREATED,
T27. LAST_UPD_BY,
T27. CREATED_BY,
T27. MODIFICATION_NUM,
T27. ROW_ID,
T24. ATTRIB_39,
T27. REMIT_ADDR_ORG_ID,
T27. REMIT_ORG_EXT_ID,
T16.NAME,
T25. ACCNT_TYPE_CD,
T27. RECAL_TAX_SRV_FLG,
T27. PROJ_ID,
T8. PROJ_NUM,
T8. BU_ID,
T5.NAME,
T8. INTEGRATION_ID,
T12. CURCY_CD,
T25. PR_BL_ADDR_ID,
T25. URL,
T27. TTL_INVC_AMT,
T27. INVC_TYPE_CD,
T27. TTL_PD_AMT,
T3. CG_ASSSET_ID,
T17. ASSET_NUM,
T27. VENDR_INVOICE_NUM,
T4. TOT_QTY_SHIP,
T4. TOT_EXTND_PRICE,
T27. ACCNT_ID,
T25. INTEGRATION_ID,
T25.NAME,
T25. BU_ID,
T25. AVAIL_CREDIT_AMT,
T10.NAME,
T27. AGREEMENT_ID,
T4. TOT_EXTND_TAX,
T27. STMT_SOURCE_CD,
T4. SRC_INVLOC_ID,
T27. STATUS_CD,
T4. TOT_QTY_BONUS,
T27. X_DEPOSIT_AMT,
T27.COMMENTS,
T27. INVC_FULLY_PAID_DT,
T26. SEQ_NUM,
T27. ELEMENT_ID,
T26. INSCLM_ID,
T14. INSCLAIM_NUM,
T27. BL_PER_ID,
T27. INS_CLAIM_ID,
T27. FN_ACCNT_ID,
T27. CUSTOMER_REF_NUM,
T27. TTL_NONREC_AMT,
T25. OU_NUM,
T24. ATTRIB_39,
T27. AMT_CURCY_CD,
T2. CCNUM_ENCRPKEY_REF,
T18. PR_DEPOSIT_ID,
T19. DISCNT_RULE_CD,
T27. ORDER_ID,
T4. STATUS_CHG_FLG,
T25. MAIN_PH_NUM,
T25. MAIN_FAX_PH_NUM,
T27. DELINQUENT_FLG,
T15. OPENING OF SESSION
T25. PR_POSTN_ID,
T4. ORDER_NUM,
T22. ADDR,
T22. Zip code
T27. INVC_NUM,
T27. INVC_DT,
T22. COUNTRIES,
T22. CITY,
T27. BL_ADDR_ID,
T23.NAME,
T27. POSTED_DT,
T20.NAME,
T27. BL_PERIOD_ID,
T27. GOODS_DLVRD_TS,
T23.NET_DAYS,
T27. PAYMENT_TERM_ID,
T23. DUE_DT,
T27. DUE_DT,
T27. VOID_REASON_TEXT,
T27. DEPT_CD,
T24. ATTRIB_60,
T24. ATTRIB_28,
T21. AMT,
T1. STATE,
T1. ADDR,
T1. ADDR_LINE_2,
T1. COUNTRIES,
T1. CITY,
T1. Zip code
T11. OPENING OF SESSION
T21. ROW_ID,
T9. ROW_ID,
T1. ROW_ID,
T13. ROW_ID,
T7. ROW_ID
Of
SIEBEL. S_ADDR_PER T1,
SIEBEL. S_PTY_PAY_PRFL T2,
SIEBEL. S_INVLOC T3,
SIEBEL. S_ORDER T4,
SIEBEL. S_ORG_EXT T5,
SIEBEL. S_POSTN T6,
SIEBEL. S_PARTY T7,
SIEBEL. S_PROJ T8,
SIEBEL. S_CON_ADDR T9,
SIEBEL. S_ORG_EXT T10,
SIEBEL. S_USER T11,
SIEBEL. S_DOC_QUOTE T12,
SIEBEL. S_ACCNT_POSTN T13,
SIEBEL. S_INS_CLAIM T14,
SIEBEL. S_USER T15,
SIEBEL. S_ORG_EXT T16,
SIEBEL. T17 S_ASSET,
SIEBEL. S_ORDER_TNTX T18,
SIEBEL. S_ORG_EXT_TNTX T19,
SIEBEL. S_PERIOD T20,
SIEBEL. S_DEPOSIT_TNT T21,
SIEBEL. T22 S_ADDR_PER,
SIEBEL. T23 S_PAYMENT_TERM,
SIEBEL. S_ORG_EXT_X T24,
SIEBEL. S_ORG_EXT T25,
SIEBEL. S_INSCLM_ELMNT T26,
SIEBEL. S_INVOICE T27
WHERE
T25. BU_ID = T10. PAR_ROW_ID (+) AND
T26. INSCLM_ID = T14. ROW_ID (+) AND
T27. ELEMENT_ID = T26. ROW_ID (+) AND
T27. LAST_UPD_BY = T15. PAR_ROW_ID (+) AND
T4. QUOTE_ID = T12. ROW_ID (+) AND
T3. CG_ASSSET_ID = T17. ROW_ID (+) AND
T27. BL_ADDR_ID = T22. ROW_ID (+) AND
T8. BU_ID = T5. PAR_ROW_ID (+) AND
T27. PER_PAY_PRFL_ID = T2. ROW_ID (+) AND
T27. REMIT_ORG_EXT_ID = T16. PAR_ROW_ID (+) AND
T27. PROJ_ID = T8. ROW_ID (+) AND
T27. BL_PERIOD_ID = T20. ROW_ID (+) AND
T27. PAYMENT_TERM_ID = T23. ROW_ID (+) AND
T12. BU_ID = T19. PAR_ROW_ID (+) AND
T27. ACCNT_ID = T25. PAR_ROW_ID (+) AND
T27. ORDER_ID = T18. ROW_ID (+) AND
T4. SRC_INVLOC_ID = T3. ROW_ID (+) AND
T27. ORDER_ID = T4. ROW_ID (+) AND
T27. ACCNT_ID = T24. PAR_ROW_ID (+) AND
T18. PR_DEPOSIT_ID = T21. ROW_ID (+) AND
T27. BL_ADDR_ID = T9. ADDR_PER_ID (+) AND
T27. ACCNT_ID = T9. ACCNT_ID (+) AND
T27. BL_ADDR_ID = T1. ROW_ID (+) AND
T25. PR_POSTN_ID = T13. POSITION_ID (+) AND
T25. ROW_ID = T13. OU_EXT_ID (+) AND
T13. POSITION_ID = T7. ROW_ID (+) AND
T13. POSITION_ID = T6. PAR_ROW_ID (+) AND
T6. PR_EMP_ID = T11. PAR_ROW_ID (+) AND
(T27. INVC_TYPE_CD =: 1) AND
(T27. DEPT_CD =: 2);
Explan exit Plan:
PLAN_TABLE_OUTPUT
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Hash value of plan: 3132260827
---------------------------------------------------------------------------------------------------------------------------
| ID | Operation | Name | Lines | Bytes | Cost (% CPU). Time |
---------------------------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | 1. 1958 | 1896K (11) | 00:50:46 |
| 1. NESTED EXTERNAL LOOPS | 1. 1958 | 1896K (11) | 00:50:46 |
| 2. NESTED EXTERNAL LOOPS | 1. 1922 | 1896K (11) | 00:50:46 |
| 3. NESTED EXTERNAL LOOPS | 1. 1885 | 1896K (11) | 00:50:46 |
| 4. NESTED EXTERNAL LOOPS | 1. 1861. 1896K (11) | 00:50:46 |
| 5. NESTED EXTERNAL LOOPS | 1. 1849. 1896K (11) | 00:50:46 |
| 6. NESTED EXTERNAL LOOPS | 1. 1817 | 1896K (11) | 00:50:46 |
| 7. NESTED EXTERNAL LOOPS | 1. 1792 | 1896K (11) | 00:50:46 |
| 8. NESTED EXTERNAL LOOPS | 1. 1771. 1896K (11) | 00:50:46 |
| 9. NESTED EXTERNAL LOOPS | 1. 1739. 1896K (11) | 00:50:46 |
| 10. NESTED EXTERNAL LOOPS | 1. 1483. 1896K (11) | 00:50:46 |
| 11. NESTED EXTERNAL LOOPS | 1. 1451. 1896K (11) | 00:50:46 |
| 12. NESTED EXTERNAL LOOPS | 1. 1419. 1896K (11) | 00:50:46 |
| 13. NESTED EXTERNAL LOOPS | 1. 1361. 1896K (11) | 00:50:46 |
| 14. NESTED EXTERNAL LOOPS | 1. 1276 | 1896K (11) | 00:50:46 |
| 15. NESTED EXTERNAL LOOPS | 1. 1202 | 1896K (11) | 00:50:46 |
| 16. NESTED EXTERNAL LOOPS | 1. 1108 | 1896K (11) | 00:50:46 |
| 17. NESTED EXTERNAL LOOPS | 1. 1087 | 1896K (11) | 00:50:46 |
| 18. NESTED EXTERNAL LOOPS | 1. 1040 | 1896K (11) | 00:50:46 |
| 19. NESTED EXTERNAL LOOPS | 1. 939 | 1896K (11) | 00:50:46 |
| 20. NESTED EXTERNAL LOOPS | 1. 894. 1896K (11) | 00:50:46 |
| 21. NESTED EXTERNAL LOOPS | 1. 868. 1896K (11) | 00:50:46 |
| 22. NESTED EXTERNAL LOOPS | 1. 843. 1896K (11) | 00:50:46 |
| 23. NESTED EXTERNAL LOOPS | 1. 824. 1896K (11) | 00:50:46 |
| 24. NESTED EXTERNAL LOOPS | 1. 690. 1896K (11) | 00:50:46 |
| 25. NESTED EXTERNAL LOOPS | 1. 613. 1896K (11) | 00:50:46 |
| 26. NESTED EXTERNAL LOOPS | 1. 457. 1896K (11) | 00:50:46 |
| * 27. TABLE ACCESS FULL | S_INVOICE | 1. 269. 1896K (11) | 00:50:46 |
| 28. TABLE ACCESS BY INDEX ROWID | S_PROJ | 1. 188. 1 (0) | 00:00:01 |
| * 29. INDEX UNIQUE SCAN | S_PROJ_P1 | 1 | | 1 (0) | 00:00:01 |
| 30. TABLE ACCESS BY INDEX ROWID | S_PAYMENT_TERM | 1. 156. 1 (0) | 00:00:01 |
| * 31. INDEX UNIQUE SCAN | S_PAYMENT_TERM_P1 | 1 | | 1 (0) | 00:00:01 |
| 32. TABLE ACCESS BY INDEX ROWID | S_INSCLM_ELMNT | 1. 77. 1 (0) | 00:00:01 |
| * 33 | INDEX UNIQUE SCAN | S_INSCLM_ELMNT_P1 | 1 | | 1 (0) | 00:00:01 |
| 34. TABLE ACCESS BY INDEX ROWID | S_INS_CLAIM | 1. 134. 1 (0) | 00:00:01 |
| * 35 | INDEX UNIQUE SCAN | S_INS_CLAIM_P1 | 1 | | 1 (0) | 00:00:01 |
| 36. TABLE ACCESS BY INDEX ROWID | S_PERIOD | 1. 19. 1 (0) | 00:00:01 |
| * 37 | INDEX UNIQUE SCAN | S_PERIOD_P1 | 1 | | 1 (0) | 00:00:01 |
| 38. TABLE ACCESS BY INDEX ROWID | S_USER | 1. 25. 2 (0) | 00:00:01 |
| * 39 | INDEX UNIQUE SCAN | S_USER_U2 | 1 | | 1 (0) | 00:00:01 |
| 40. TABLE ACCESS BY INDEX ROWID | S_ORDER_TNTX | 1. 26. 2 (0) | 00:00:01 |
| * 41. INDEX UNIQUE SCAN | S_ORDER_TNTX_P1 | 1 | | 1 (0) | 00:00:01 |
| 42. TABLE ACCESS BY INDEX ROWID | S_DEPOSIT_TNT | 1. 45. 1 (0) | 00:00:01 |
| * 43. INDEX UNIQUE SCAN | S_DEPOSIT_TNT_P1 | 1 | | 1 (0) | 00:00:01 |
| 44. TABLE ACCESS BY INDEX ROWID | S_ORDER | 1. 101 | 2 (0) | 00:00:01 |
| * 45 | INDEX UNIQUE SCAN | S_ORDER_P1 | 1 | | 1 (0) | 00:00:01 |
| 46. TABLE ACCESS BY INDEX ROWID | S_INVLOC | 1. 47. 1 (0) | 00:00:01 |
| * 47 | INDEX UNIQUE SCAN | S_INVLOC_P1 | 1 | | 1 (0) | 00:00:01 |
| 48. TABLE ACCESS BY INDEX ROWID | S_DOC_QUOTE | 1. 21. 1 (0) | 00:00:01 |
| * 49 | INDEX UNIQUE SCAN | S_DOC_QUOTE_P1 | 1 | | 1 (0) | 00:00:01 |
| 50. TABLE ACCESS BY INDEX ROWID | S_ORG_EXT_TNTX | 1. 94. 1 (0) | 00:00:01 |
| * 51 | INDEX RANGE SCAN | S_ORG_EXT_TNTX_U1 | 1 | | 1 (0) | 00:00:01 |
| 52. TABLE ACCESS BY INDEX ROWID | S_PTY_PAY_PRFL | 1. 74. 1 (0) | 00:00:01 |
| * 53 | INDEX UNIQUE SCAN | S_PTY_PAY_PRFL_P1 | 1 | | 1 (0) | 00:00:01 |
| 54. TABLE ACCESS BY INDEX ROWID | S_ADDR_PER | 1. 85. 2 (0) | 00:00:01 |
| * 55 | INDEX UNIQUE SCAN | S_ADDR_PER_P1 | 1 | | 1 (0) | 00:00:01 |
| 56. TABLE ACCESS BY INDEX ROWID | S_ADDR_PER | 1. 58. 1 (0) | 00:00:01 |
| * 57 | INDEX UNIQUE SCAN | S_ADDR_PER_P1 | 1 | | 1 (0) | 00:00:01 |
| 58. TABLE ACCESS BY INDEX ROWID | S_ORG_EXT | 1. 32. 1 (0) | 00:00:01 |
| * 59 | INDEX UNIQUE SCAN | S_ORG_EXT_U3 | 1 | | 1 (0) | 00:00:01 |
| 60. TABLE ACCESS BY INDEX ROWID | S_ORG_EXT | 1. 32. 1 (0) | 00:00:01 |
| * 61. INDEX UNIQUE SCAN | S_ORG_EXT_U3 | 1 | | 1 (0) | 00:00:01 |
| 62. TABLE ACCESS BY INDEX ROWID | S_ORG_EXT | 1. 256. 2 (0) | 00:00:01 |
| * 63. INDEX UNIQUE SCAN | S_ORG_EXT_U3 | 1 | | 1 (0) | 00:00:01 |
| 64. TABLE ACCESS BY INDEX ROWID | S_ACCNT_POSTN | 1. 32. 3 (0) | 00:00:01 |
| * 65 | INDEX RANGE SCAN | S_ACCNT_POSTN_U1 | 1 | | 2 (0) | 00:00:01 |
| 66. TABLE ACCESS BY INDEX ROWID | S_POSTN | 1. 21. 1 (0) | 00:00:01 |
| * 67. INDEX UNIQUE SCAN | S_POSTN_U2 | 1 | | 1 (0) | 00:00:01 |
| 68. TABLE ACCESS BY INDEX ROWID | S_USER | 1. 25. 2 (0) | 00:00:01 |
| * 69 | INDEX UNIQUE SCAN | S_USER_U2 | 1 | | 1 (0) | 00:00:01 |
| 70. TABLE ACCESS BY INDEX ROWID | S_ORG_EXT | 1. 32. 2 (0) | 00:00:01 |
| * 71 | INDEX UNIQUE SCAN | S_ORG_EXT_U3 | 1 | | 1 (0) | 00:00:01 |
| * 72 | INDEX UNIQUE SCAN | S_PARTY_P1 | 1. 12. 1 (0) | 00:00:01 |
| 73. TABLE ACCESS BY INDEX ROWID | S_ASSET | 1. 24. 2 (0) | 00:00:01 |
| * 74 | INDEX UNIQUE SCAN | S_ASSET_P1 | 1 | | 2 (0) | 00:00:01 |
| 75. TABLE ACCESS BY INDEX ROWID | S_ORG_EXT_X | 1. 37. 2 (0) | 00:00:01 |
| * 76 | INDEX RANGE SCAN | S_ORG_EXT_X_U1 | 1 | | 2 (0) | 00:00:01 |
| 77. TABLE ACCESS BY INDEX ROWID | S_CON_ADDR | 1. 36. 3 (0) | 00:00:01 |
| * 78 | INDEX RANGE SCAN | S_CON_ADDR_U1 | 1 | | 2 (0) | 00:00:01 |
---------------------------------------------------------------------------------------------------------------------------
Information of predicates (identified by the operation identity card):
---------------------------------------------------
27 - filter("T27".") DEPT_CD "=: 2 AND"T27"". "" INVC_TYPE_CD "(=:1)"
29 - access("T27".") PROJ_ID '= 'T8'.' ROW_ID "(+))"
31 - access("T27".") PAYMENT_TERM_ID "="T23"." ROW_ID "(+))"
33 - access("T27".") ELEMENT_ID "="T26"." ROW_ID "(+))"
35 - access("T26".") INSCLM_ID "="T14"." ROW_ID "(+))"
37 - access("T27".") BL_PERIOD_ID '= 'T20'.' ROW_ID "(+))"
39 - access("T27".") LAST_UPD_BY "="T15"." PAR_ROW_ID "(+))"
41 - access("T27".") ORDER_ID "="T18"." ROW_ID "(+))"
43 - access("T18".") PR_DEPOSIT_ID "="T21"." ROW_ID "(+))"
45 - access("T27".") ORDER_ID "="T4"." ROW_ID "(+))"
47 - access("T4".") SRC_INVLOC_ID '= 'T3'.' ROW_ID "(+))"
49 - access("T4".") QUOTE_ID "="T12"." ROW_ID "(+))"
51 - access("T12".") BU_ID "="T19"." PAR_ROW_ID "(+))"
53 - access("T27".") PER_PAY_PRFL_ID '= 'T2'.' ROW_ID "(+))"
55 - access("T27".") BL_ADDR_ID '= 'T1'.' ROW_ID "(+))"
57 - access("T27".") BL_ADDR_ID '= 'T22'.' ROW_ID "(+))"
59 - access("T8".") BU_ID '= 'T5'.' PAR_ROW_ID "(+))"
61 - access("T27".") REMIT_ORG_EXT_ID '= 'T16'.' PAR_ROW_ID "(+))"
63 - access("T27".") ACCNT_ID '= 'T25'.' PAR_ROW_ID "(+))"
65 - access("T25".") ROW_ID "= 'T13'." OU_EXT_ID "(+) AND 'T25'." ' PR_POSTN_ID '= "T13". "POSITION_ID" (+)) "
67 - access("T13".") POSITION_ID "="T6"." PAR_ROW_ID "(+))"
69 - access("T6".") PR_EMP_ID '= 'T11'.' PAR_ROW_ID "(+))"
71 - access("T25".") BU_ID '= 'T10'.' PAR_ROW_ID "(+))"
72 - access("T13".") POSITION_ID '= 'T7'.' ROW_ID "(+))"
74 - access("T3".") CG_ASSSET_ID "="T17"." ROW_ID "(+))"
76 - access("T27".") ACCNT_ID '= 'T24'.' PAR_ROW_ID "(+))"
78 - access("T27".") BL_ADDR_ID "="T9"." ADDR_PER_ID "(+) AND 'T27'." "ACCNT_ID"= "T9". "ACCNT_ID" (+)) "
filter ("T27". "ACCNT_ID"= "T9"." ACCNT_ID "(+))"
117 selected lines.
We use 10.2.0.3 oracle version.Hello
According to the plan of the explain command, > 99% of the cost of the query comes from a single operation - step 27, a comprehensive analysis of the S_INVOICE table.
This probably means that there is no index can be used on DEPT_CD and/or INVC_TYPE_CD.So start by setting SELECT * FROM S_INVOICE WHERE ("T27" T27. "DEPT_CD" =: 2 AND "T27" "." " INVC_TYPE_CD "(=:1)"
BTW the plan shows that the 1 row should be returned, while Oracle actually returns 117 - this means that the optimizer estimates are not very reliable here.
Best regards
Nikolai -
OUTER JOIN query returns the results of JOIN IN-HOUSE 11.2.0.1.0
I'm data transfer in 11.2.01.0 (Windows XP 32-bit) and I wanted to compare the sizes of table with the same Table name in two different patterns, ML and SILENT, with a FULL OUTER JOIN (to account for all the tables and NULL values in a diagram).
The scheme of ML has 176 tables: schema TUT a 133 tables. The use of a standard INNER JOIN gives 131 paintings.
I get precisely the results with a FULL OUTER JOIN I get with an INTERNAL JOIN (not the same NULL values so I know they exist).
This happens in SQL-Plus, SQL_Developer and using Oracle Wire pilot of Data_Direct.
Here is the code:
Login: SYS as SYSDBA or SYSTEM (same results for either)
SELECT M.TABLE_NAME, M.NUM_ROWS, T.TABLE_NAME, T.NUM_ROWS
OF SYS. ALL_TABLES M FULL OUTER JOIN SYS. ALL_TABLES T ON M.TABLE_NAME = T.TABLE_NAME
WHERE
M.OWNER = 'ML' AND
T.OWNER = 'TUT';
Produce the same results with LEFT OUTER joins and RIGHT OUTER joins in ASI and Oracle (+) syntax.
Any thoughts?Hello
If you read what I posted, forget it. MScallion (below) gave the correct answerr.
If conditions such as
owner = 'ML'
in the WHERE clause, and then they will reject the rows of the result set formed by the join condition.
The inner join returns only 131 lines where the two 'paintings' have the same table_names.
The outer joins return multiple lines (133, 176 or 178) before the place WHERE the provision is applied , but the WHERE clause eliminates all lines except the 131 found by the inner join.Published by: Frank Kulash, July 10, 2010 14:23
-
Hi gurus,
Left outer join:
-------------------
Select * from A LEFT OUTER JOIN B on A.col = B.col;
by definition, a left outer join brings the rows that match the join condition and lines not corresponding to table A.
My question here is "corresponding to B and no matching rows in A" is that nothing, but... SELECT * FROM A;
can someone pls clarity...
Thank you.
Imagine that you had:
TableA
COLUMN1 COLUMN2
'A' 1
'B' 2
'C' 3
TABLEB
COLUMN1 COLUMN2
'A' 'X1'
'A' 'X2'
'B' 'Y'
'D' 'Z'
SELECT * FROM TABLEA;
A 1
B 2
C 3
Now, if you want to join (first column is either in table A or B, (deuxieme from tableA, third table B)
SELECT * FROM TABLEA A JOIN TABLEB B ON (A.COLUMN1 = B.COLUMN1)
A 1 X 1
A 1 X 2
B 2 Y
SELECT * FROM TABLE LEFT B EXTERNAL ON (A.COLUMN1 = B.COLUMN1) JOIN TABLE
A 1 X 1
A 1 X 2
B 2 Y
C 3 {null}
SELECT * FROM TABLE A TABLE RIGHT OUTER JOIN B (A.COLUMN1 = B.COLUMN1)
A 1 X 1
A 1 X 2
B 2 Y
D {null} Z
SELECT * FROM TABLE A TABLE FULL OUTER JOIN B (A.COLUMN1 = B.COLUMN1)
A 1 X 1
A 1 X 2
B 2 Y
C 3 {null}
D {null} Z
HTH
Maybe you are looking for
-
It seems that this started when I updated to FF 16.0.1 version. I'm afraid to upgrade to version 16.o.2 until I can get this resolved. I'm going crazy trying to figure out how can I add anything. My 'story' is also completely empty as no history is s
-
iMac 27 "Late 2009 EtreCheck poster"Drive Failure!"
Hello My iMac has been terribly slow recently. 27 "late 2009. Intel i7 8GM RAM 1 TB drive. I was doing the seemings beach ball every few minutes. I ran an EtreCheck and that's what it produces: For me, obviously the entrance of the inability to driv
-
Disable the unwanted selection on the hover function
Once again, my Lenovo Thinkpad 430 (running Windows 7) is constantly selecting what the pointer is sitting on. This happens regularly, and it drives me crazy. I was able to cure it in the past, but today I was unable to do so. The feature "Activate a
-
I am trying to transfer my files to my new laptop with Windows 7 for my old laptop with Windows XP Professional, using the Windows Easy Transfer, that I found on my old laptop. I tried to make the transfer through my home wireless network and when
-
Edit, find in Adobe Acrobat Reader
When I make a change, be on a document from adobe, it is necessary that I can change, but when I click on continue moving onto the next 'find' it always brings back me at the beginning of the document. Then I have to go right through the of to make i