Help with outer joins in Oracle!!
so far this is what i've come up with and the code below does not work. Can anyone please help me on how the sytanx of left joins and how to use multiple left joins in a single query in oracle?
SELECT a.*, b.Position_CD, c.Skill_CD, d.Team_Name, d.Team_Country, d.Club, e.Structure_Name
FROM Roster a, Roster_position b, roster_skill c, Team d, Team_Structure e
where (a.Roster_ID = ((b.Roster_ID= c.Roster_Id(+)) b.roster_id(+)).......
I dont' know how to add more left joins!
Here is the query I'm trying to duplicate (which is a query from Ms Access databaase which works fine).
SELECT a.*, b.Position_CD, c.Skill_CD, d.Team_Name, d.Team_Country, d.Club, e.Structure_Name
from ((Roster a LEFT JOIN (Roster_Position b LEFT JOIN Roster_Skill c ON b.Roster_ID=c.Roster_ID) ON a.Roster_ID=b.Roster_ID) LEFT JOIN Team d ON a.Team_CD=d.Team_CD) LEFT JOIN Team_Structure e ON a.Team_Structure_CD=e.Team_Structure_CD
ORDER BY a.Roster_Id;
Any help or comments are greatly appreciated
First,
I am not one of the leading SQL brains here...but I'm taking a stab, nonetheless.
Second,
Here's my best guess - and it seems to me that it should work as there are not two outer joins between any two tables. I hope I decoded your joins correctly - quite a mess that Access syntax!
SELECT a.*, b.position_cd, c.skill_cd, d.team_name, d.team_country, d.club, e.structure_name
FROM ROSTER a, ROSTER_POSITION b, ROSTER_SKILL c, TEAM d, TEAM_STRUCTURE e
WHERE a.roster_id = b.roster_id(+)
AND b.roster_id = c.roster_id(+)
AND a.team_cd = d.team_cd(+)
AND a.team_structure = e.team_structure(+);Third,
As an architect-dude, it seems to me that you have a serious
modeling problem to need so many outer joins in such a basic
grab of data. In any scale other than minute, the performance
of this model will suffer dramatically. Specifically, why can't
ROSTER have an equijoin with TEAM and with TEAM_STRUCTURE - as they
appear to be lookup tables...
Good Luck
(I'm certain you'll get better SQL from the others),
Michael O'Neill
Publisher of the PigiWiki
clever-idea.com
Similar Messages
-
I have two tables:
PS and Entity whose data are as follows
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('26-DEC-08','DD-MON-RR HH.MI.SSXFF AM'),1);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('26-DEC-08','DD-MON-RR HH.MI.SSXFF AM'),3);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('26-DEC-08','DD-MON-RR HH.MI.SSXFF AM'),6);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('26-DEC-08','DD-MON-RR HH.MI.SSXFF AM'),10);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('26-DEC-08','DD-MON-RR HH.MI.SSXFF AM'),13);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('27-JAN-09','DD-MON-RR HH.MI.SSXFF AM'),13);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('27-JAN-09','DD-MON-RR HH.MI.SSXFF AM'),10);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('27-JAN-09','DD-MON-RR HH.MI.SSXFF AM'),6);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('27-JAN-09','DD-MON-RR HH.MI.SSXFF AM'),3);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('27-JAN-09','DD-MON-RR HH.MI.SSXFF AM'),1);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('26-FEB-09','DD-MON-RR HH.MI.SSXFF AM'),13);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('26-FEB-09','DD-MON-RR HH.MI.SSXFF AM'),10);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('26-FEB-09','DD-MON-RR HH.MI.SSXFF AM'),6);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('26-FEB-09','DD-MON-RR HH.MI.SSXFF AM'),3);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('26-FEB-09','DD-MON-RR HH.MI.SSXFF AM'),1);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('30-MAR-09','DD-MON-RR HH.MI.SSXFF AM'),1);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('30-MAR-09','DD-MON-RR HH.MI.SSXFF AM'),3);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('30-MAR-09','DD-MON-RR HH.MI.SSXFF AM'),6);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('30-MAR-09','DD-MON-RR HH.MI.SSXFF AM'),10);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('30-MAR-09','DD-MON-RR HH.MI.SSXFF AM'),13);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('28-APR-09','DD-MON-RR HH.MI.SSXFF AM'),13);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('28-APR-09','DD-MON-RR HH.MI.SSXFF AM'),10);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('28-APR-09','DD-MON-RR HH.MI.SSXFF AM'),6);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('28-APR-09','DD-MON-RR HH.MI.SSXFF AM'),3);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('28-APR-09','DD-MON-RR HH.MI.SSXFF AM'),1);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('29-MAY-09','DD-MON-RR HH.MI.SSXFF AM'),14);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('29-MAY-09','DD-MON-RR HH.MI.SSXFF AM'),9);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('29-MAY-09','DD-MON-RR HH.MI.SSXFF AM'),13);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('29-MAY-09','DD-MON-RR HH.MI.SSXFF AM'),10);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('29-MAY-09','DD-MON-RR HH.MI.SSXFF AM'),6);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('29-MAY-09','DD-MON-RR HH.MI.SSXFF AM'),3);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('29-MAY-09','DD-MON-RR HH.MI.SSXFF AM'),1);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('26-JUN-09','DD-MON-RR HH.MI.SSXFF AM'),13);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('26-JUN-09','DD-MON-RR HH.MI.SSXFF AM'),10);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('26-JUN-09','DD-MON-RR HH.MI.SSXFF AM'),6);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('26-JUN-09','DD-MON-RR HH.MI.SSXFF AM'),3);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('26-JUN-09','DD-MON-RR HH.MI.SSXFF AM'),1);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('28-JUL-09','DD-MON-RR HH.MI.SSXFF AM'),14);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('28-JUL-09','DD-MON-RR HH.MI.SSXFF AM'),9);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('28-JUL-09','DD-MON-RR HH.MI.SSXFF AM'),13);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('28-JUL-09','DD-MON-RR HH.MI.SSXFF AM'),10);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('28-JUL-09','DD-MON-RR HH.MI.SSXFF AM'),6);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('28-JUL-09','DD-MON-RR HH.MI.SSXFF AM'),3);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('28-JUL-09','DD-MON-RR HH.MI.SSXFF AM'),1);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('26-AUG-09','DD-MON-RR HH.MI.SSXFF AM'),14);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('26-AUG-09','DD-MON-RR HH.MI.SSXFF AM'),9);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('26-AUG-09','DD-MON-RR HH.MI.SSXFF AM'),13);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('26-AUG-09','DD-MON-RR HH.MI.SSXFF AM'),10);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('26-AUG-09','DD-MON-RR HH.MI.SSXFF AM'),6);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('26-AUG-09','DD-MON-RR HH.MI.SSXFF AM'),3);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('26-AUG-09','DD-MON-RR HH.MI.SSXFF AM'),1);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('25-SEP-09','DD-MON-RR HH.MI.SSXFF AM'),14);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('25-SEP-09','DD-MON-RR HH.MI.SSXFF AM'),9);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('25-SEP-09','DD-MON-RR HH.MI.SSXFF AM'),13);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('25-SEP-09','DD-MON-RR HH.MI.SSXFF AM'),10);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('25-SEP-09','DD-MON-RR HH.MI.SSXFF AM'),6);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('25-SEP-09','DD-MON-RR HH.MI.SSXFF AM'),3);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('25-SEP-09','DD-MON-RR HH.MI.SSXFF AM'),1);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('26-OCT-09','DD-MON-RR HH.MI.SSXFF AM'),14);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('26-OCT-09','DD-MON-RR HH.MI.SSXFF AM'),9);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('26-OCT-09','DD-MON-RR HH.MI.SSXFF AM'),13);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('26-OCT-09','DD-MON-RR HH.MI.SSXFF AM'),10);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('26-OCT-09','DD-MON-RR HH.MI.SSXFF AM'),6);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('26-OCT-09','DD-MON-RR HH.MI.SSXFF AM'),3);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('26-OCT-09','DD-MON-RR HH.MI.SSXFF AM'),1);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('24-NOV-09','DD-MON-RR HH.MI.SSXFF AM'),14);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('24-NOV-09','DD-MON-RR HH.MI.SSXFF AM'),9);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('24-NOV-09','DD-MON-RR HH.MI.SSXFF AM'),13);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('24-NOV-09','DD-MON-RR HH.MI.SSXFF AM'),10);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('24-NOV-09','DD-MON-RR HH.MI.SSXFF AM'),6);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('24-NOV-09','DD-MON-RR HH.MI.SSXFF AM'),3);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('24-NOV-09','DD-MON-RR HH.MI.SSXFF AM'),1);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('25-DEC-09','DD-MON-RR HH.MI.SSXFF AM'),9);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('25-DEC-09','DD-MON-RR HH.MI.SSXFF AM'),13);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('25-DEC-09','DD-MON-RR HH.MI.SSXFF AM'),10);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('25-DEC-09','DD-MON-RR HH.MI.SSXFF AM'),6);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('25-DEC-09','DD-MON-RR HH.MI.SSXFF AM'),3);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('25-DEC-09','DD-MON-RR HH.MI.SSXFF AM'),1);
Insert into PS (DATE_TIME,ENTITY_ID) values (to_timestamp('25-DEC-09','DD-MON-RR HH.MI.SSXFF AM'),14);
Entity:
Insert into ENTITY (ENTITY_ID,ENTITY_ADDRESS) values (1,'AAA');
Insert into ENTITY (ENTITY_ID,ENTITY_ADDRESS) values (3,'CCC');
Insert into ENTITY (ENTITY_ID,ENTITY_ADDRESS) values (6,'DDD');
Insert into ENTITY (ENTITY_ID,ENTITY_ADDRESS) values (9,'EEE');
Insert into ENTITY (ENTITY_ID,ENTITY_ADDRESS) values (10,'FFF');
Insert into ENTITY (ENTITY_ID,ENTITY_ADDRESS) values (13,'GGG');
Insert into ENTITY (ENTITY_ID,ENTITY_ADDRESS) values (14,'HHH');
I want to display data for each entity available in entity table
What is wrong with this query??
Select ps.date_time,ps.entity_id,et.entity_id from entity et left outer join PS ps on (et.entity_id = ps.entity_id)
This query gives me result like
26-DEC-08 1 1
26-DEC-08 3 3
26-DEC-08 6 6
26-DEC-08 10 10
26-DEC-08 13 13
27-JAN-09 13 13
27-JAN-09 10 10
27-JAN-09 6 6
27-JAN-09 3 3
27-JAN-09 1 1...
But for 26-Dec-08, i want to display
26-DEC-08 1 1
26-DEC-08 3 3
26-DEC-08 6 6
26-DEC-08 10 10
26-DEC-08 13 13
26-DEC-08 NULL 9
26-DEC-09 NULL 14
27-JAN-09 13 13
27-JAN-09 10 10
27-JAN-09 6 6
27-JAN-09 3 3
27-JAN-09 1 1
But the unmatching ids are not displaying when i am using the outer join..please help me..Almost there.
In this case you need a partitioned outer join, partitioning by date_time:
SQL> Select ps.date_time
2 , ps.entity_id
3 , et.entity_id
4 from ps partition by (ps.date_time)
5 right outer join entity et on (et.entity_id = ps.entity_id)
6 /
DATE_TIME ENTITY_ID ENTITY_ID
26-12-08 00:00:00,000000 1 1
26-12-08 00:00:00,000000 3 3
26-12-08 00:00:00,000000 6 6
26-12-08 00:00:00,000000 9
26-12-08 00:00:00,000000 10 10
26-12-08 00:00:00,000000 13 13
26-12-08 00:00:00,000000 14
27-01-09 00:00:00,000000 1 1
27-01-09 00:00:00,000000 3 3
27-01-09 00:00:00,000000 6 6
27-01-09 00:00:00,000000 9
27-01-09 00:00:00,000000 10 10
27-01-09 00:00:00,000000 13 13
27-01-09 00:00:00,000000 14
26-02-09 00:00:00,000000 1 1
26-02-09 00:00:00,000000 3 3
26-02-09 00:00:00,000000 6 6
26-02-09 00:00:00,000000 9
26-02-09 00:00:00,000000 10 10
26-02-09 00:00:00,000000 13 13
26-02-09 00:00:00,000000 14
30-03-09 00:00:00,000000 1 1
30-03-09 00:00:00,000000 3 3
30-03-09 00:00:00,000000 6 6
30-03-09 00:00:00,000000 9
30-03-09 00:00:00,000000 10 10
30-03-09 00:00:00,000000 13 13
30-03-09 00:00:00,000000 14
28-04-09 00:00:00,000000 1 1
28-04-09 00:00:00,000000 3 3
28-04-09 00:00:00,000000 6 6
28-04-09 00:00:00,000000 9
28-04-09 00:00:00,000000 10 10
28-04-09 00:00:00,000000 13 13
28-04-09 00:00:00,000000 14
29-05-09 00:00:00,000000 1 1
29-05-09 00:00:00,000000 3 3
29-05-09 00:00:00,000000 6 6
29-05-09 00:00:00,000000 9 9
29-05-09 00:00:00,000000 10 10
29-05-09 00:00:00,000000 13 13
29-05-09 00:00:00,000000 14 14
26-06-09 00:00:00,000000 1 1
26-06-09 00:00:00,000000 3 3
26-06-09 00:00:00,000000 6 6
26-06-09 00:00:00,000000 9
26-06-09 00:00:00,000000 10 10
26-06-09 00:00:00,000000 13 13
26-06-09 00:00:00,000000 14
28-07-09 00:00:00,000000 1 1
28-07-09 00:00:00,000000 3 3
28-07-09 00:00:00,000000 6 6
28-07-09 00:00:00,000000 9 9
28-07-09 00:00:00,000000 10 10
28-07-09 00:00:00,000000 13 13
28-07-09 00:00:00,000000 14 14
26-08-09 00:00:00,000000 1 1
26-08-09 00:00:00,000000 3 3
26-08-09 00:00:00,000000 6 6
26-08-09 00:00:00,000000 9 9
26-08-09 00:00:00,000000 10 10
26-08-09 00:00:00,000000 13 13
26-08-09 00:00:00,000000 14 14
25-09-09 00:00:00,000000 1 1
25-09-09 00:00:00,000000 3 3
25-09-09 00:00:00,000000 6 6
25-09-09 00:00:00,000000 9 9
25-09-09 00:00:00,000000 10 10
25-09-09 00:00:00,000000 13 13
25-09-09 00:00:00,000000 14 14
26-10-09 00:00:00,000000 1 1
26-10-09 00:00:00,000000 3 3
26-10-09 00:00:00,000000 6 6
26-10-09 00:00:00,000000 9 9
26-10-09 00:00:00,000000 10 10
26-10-09 00:00:00,000000 13 13
26-10-09 00:00:00,000000 14 14
24-11-09 00:00:00,000000 1 1
24-11-09 00:00:00,000000 3 3
24-11-09 00:00:00,000000 6 6
24-11-09 00:00:00,000000 9 9
24-11-09 00:00:00,000000 10 10
24-11-09 00:00:00,000000 13 13
24-11-09 00:00:00,000000 14 14
25-12-09 00:00:00,000000 1 1
25-12-09 00:00:00,000000 3 3
25-12-09 00:00:00,000000 6 6
25-12-09 00:00:00,000000 9 9
25-12-09 00:00:00,000000 10 10
25-12-09 00:00:00,000000 13 13
25-12-09 00:00:00,000000 14 14
91 rijen zijn geselecteerd.Partitioned outer join became available somewhere during version 10. They are described here: http://download.oracle.com/docs/cd/B28359_01/server.111/b28314/tdpdw_sql.htm#TDPDW00736
Regards,
Rob. -
I have the following table structure,
Table - 1_
ID | Information
1 | abcadskasasa
2 | asdasdasdasd
3 | saeqdfdvsfcsc
Table - 2_
ID | PID
1 | 12
1 | 13
2 | 14
1 | 15
1 | 16
2 | 12
Table - 3_
ID | PARID
1 | 12
2 | 14
1 | 15
Now I want to select for each ID in table 1, the count of number of PID from table 2 and count of number of PARID from table 3.
Desired output:_
ID | COUNT_PID | COUNT_PARID
1 | 4 | 2
2 | 2 | 1
3 | 0 | 0
Could anyone please help me out with this. I am trying to make use of outer joins, but as I work mostly on the front end so, not able to come up with a proper solution for the above.
Thanks in advance,
TejasHi, Tejas,
You might have been doing the outer join correctly.
There's another problem here: joining table_1 to two other tables with which it has a one-to-many relationship.
If you were joining table_1 to just one other table, you could say:
SELECT t1.id
, COUNT (t2.pid) AS count_pid
FROM table_1 t1
LEFT OUTER JOIN table_2 t2 ON t1.id = t2.id
GROUP BY t1.id
ORDER BY t1.id;You could have done the exact same thing with table_3 instead of table_2.
But you can't do the same thing with both table_2 and table_3 at the same time: that would be like cross-joining table_2 and table_3. Instead of showing id=1 having count_pid=4 and count_parid=2, you would get cout_pid=8 and count_parid=8 (since 8 = 4 * 2).
You can do a separate GROUP BY on (at least) one of the tables.
This gets the right results. In the main query, there is only one one-to-many relationship.
WITH t3_summary AS
SELECT id
, COUNT (parid) AS count_parid
FROM table_3
GROUP BY id
SELECT t1.id
, COUNT (t2.pid) AS count_pid
, MAX (t3.count_parid) AS count_parid
FROM table_1 t1
LEFT OUTER JOIN table_2 t2 ON t1.id = t2.id
LEFT OUTER JOIN t3_summary t3 ON t1.id = t3.id
GROUP BY t1.id
ORDER BY t1.id; -
Need help with outer join filter.
Need a little help filtering a resultset and I cant seem to find a proper way to do this.
/*table*/
create table invoice( farinvc_invh_code varchar2(100),
farinvc_item varchar2(100),
farinvc_po varchar2(100)
create table po(
supplier_number varchar2(60),
supplier_invoice_no varchar2(60),
po_number varchar2(60),
run_date varchar2(60),
PO_LINE_NUMBER varchar2(60) );
/*data*/
INSERT INTO "INVOICE" (FARINVC_INVH_CODE, FARINVC_ITEM, FARINVC_PO_ITEM) VALUES ('I0554164', '1', 'P0142245');
INSERT INTO "INVOICE" (FARINVC_INVH_CODE, FARINVC_ITEM, FARINVC_PO_ITEM) VALUES ('I0554164', '3', 'P0142245');
INSERT INTO "INVOICE" (FARINVC_INVH_CODE, FARINVC_ITEM, FARINVC_PO) VALUES ('I0554165', '1', 'P0142246');
INSERT INTO "INVOICE" (FARINVC_INVH_CODE, FARINVC_ITEM, FARINVC_PO) VALUES ('I0554165', '2', 'P0142246');
INSERT INTO "PO" (SUPPLIER_NUMBER, SUPPLIER_INVOICE_NO, PO_NUMBER, RUN_DATE, PO_LINE_NUMBER) VALUES ('914100121', '529132260', 'P0142245', '21-NOV-12', '1');
INSERT INTO "PO" (SUPPLIER_NUMBER, SUPPLIER_INVOICE_NO, PO_NUMBER, RUN_DATE, PO_LINE_NUMBER) VALUES ('914100121', '529137831', 'P0142245', '21-NOV-12', '3');
INSERT INTO "PO" (SUPPLIER_NUMBER, SUPPLIER_INVOICE_NO, PO_NUMBER, RUN_DATE, PO_LINE_NUMBER) VALUES ('914100121', '529137831', 'P0142245', '21-NOV-12', '2');
INSERT INTO "PO" (SUPPLIER_NUMBER, SUPPLIER_INVOICE_NO, PO_NUMBER, RUN_DATE, PO_LINE_NUMBER) VALUES ('914100122', '145678', 'P0142246', '22-NOV-12', '1');
INSERT INTO "PO" (SUPPLIER_NUMBER, SUPPLIER_INVOICE_NO, PO_NUMBER, RUN_DATE, PO_LINE_NUMBER) VALUES ('914100122', '145679', 'P0142246', '22-NOV-12', '2');query im executing.
SELECT farinvc_invh_code,
supplier_number,
supplier_invoice_no,
farinvc_item,
farinvc_po ,
po_number,
run_date,
PO_LINE_NUMBER
FROM INVOICE, PO
WHERE PO_NUMBER = FARINVC_PO(+)
AND FARINVC_ITEM(+) = PO_LINE_NUMBER
result
"FARINVC_INVH_CODE" "SUPPLIER_NUMBER" "SUPPLIER_INVOICE_NO" "FARINVC_ITEM" "FARINVC_PO" "PO_NUMBER" "RUN_DATE" "PO_LINE_NUMBER"
"I0554165" "914100122" "145678" "1" "P0142246" "P0142246" "22-NOV-12" "1"
"I0554165" "914100122" "145679" "2" "P0142246" "P0142246" "22-NOV-12" "2"
"I0554164" "914100121" "529132260" "1" "P0142245" "P0142245" "21-NOV-12" "1"
"I0554164" "914100121" "529137831" "3" "P0142245" "P0142245" "21-NOV-12" "3"
"" "914100121" "529137831" "" "" "P0142245" "21-NOV-12" "2" this is a much larger table and I took an excerpt in order to keep things clear and understanding. I would like to filter this result set to only show the lines that have have the po numbers are the same and line are the same but there is an extra item. in other words like such.
"FARINVC_INVH_CODE" "SUPPLIER_NUMBER" "SUPPLIER_INVOICE_NO" "FARINVC_ITEM" "FARINVC_PO" "PO_NUMBER" "RUN_DATE" "PO_LINE_NUMBER"
"I0554164" "914100121" "529132260" "1" "P0142245" "P0142245" "21-NOV-12" "1"
"I0554164" "914100121" "529137831" "3" "P0142245" "P0142245" "21-NOV-12" "3"
"" "914100121" "529137831" "" "" "P0142245" "21-NOV-12" "2"fair enough frank lets add some extra data to the tables.
for example.
INSERT INTO "INVOICE" (FARINVC_INVH_CODE, FARINVC_ITEM, FARINVC_PO) VALUES ('I0554167', '1', 'P0142447')
INSERT INTO "INVOICE" (FARINVC_INVH_CODE, FARINVC_ITEM, FARINVC_PO) VALUES ('I0554167', '2', 'P0142447')
INSERT INTO "PO" (SUPPLIER_NUMBER, SUPPLIER_INVOICE_NO, PO_NUMBER, RUN_DATE, PO_LINE_NUMBER) VALUES ('914100123', 'INV1', 'P0142247', '25-NOV-12', '1')
INSERT INTO "PO" (SUPPLIER_NUMBER, SUPPLIER_INVOICE_NO, PO_NUMBER, RUN_DATE, PO_LINE_NUMBER) VALUES ('914100123', 'INV2', 'P0142247', '25-NOV-12', '2')
INSERT INTO "PO" (SUPPLIER_NUMBER, SUPPLIER_INVOICE_NO, PO_NUMBER, RUN_DATE, PO_LINE_NUMBER) VALUES ('914100123', 'INV3', 'P0142247', '25-NOV-12', '3')if we run the query above we get
"FARINVC_INVH_CODE" "SUPPLIER_NUMBER" "SUPPLIER_INVOICE_NO" "FARINVC_ITEM" "FARINVC_PO" "PO_NUMBER" "RUN_DATE" "PO_LINE_NUMBER"
"I0554164" "914100121" "529132260" "1" "P0142245" "P0142245" "21-NOV-12" "1"
"I0554164" "914100121" "529137831" "3" "P0142245" "P0142245" "21-NOV-12" "3"
"" "914100121" "529137831" "" "" "P0142245" "21-NOV-12" "2"
"" "914100123" "INV2" "" "" "P0142247" "25-NOV-12" "2"
"" "914100123" "INV1" "" "" "P0142247" "25-NOV-12" "1"
"" "914100123" "INV3" "" "" "P0142247" "25-NOV-12" "3" where really what im trying to target is pos and lines that have a match in both tables and there is additional items from the po table that do not have have a match from the invoice table. Furthermore i would only like to see the items that are repeating invoice numbers, in other words my result here should still only be, because "SUPPLIER_INVOICE_NO" is repeating and it does find a match for the po in the invoice table but yet there is an item with the same invoice and po in the po table that does not have a match in the invoice table.
"FARINVC_INVH_CODE" "SUPPLIER_NUMBER" "SUPPLIER_INVOICE_NO" "FARINVC_ITEM" "FARINVC_PO" "PO_NUMBER" "RUN_DATE" "PO_LINE_NUMBER"
"I0554164" "914100121" "529132260" "1" "P0142245" "P0142245" "21-NOV-12" "1"
"I0554164" "914100121" "529137831" "3" "P0142245" "P0142245" "21-NOV-12" "3"
"" "914100121" "529137831" "" "" "P0142245" "21-NOV-12" "2" hope that makes sense, and thanks for working with me on this.
Edited by: mlov83 on Dec 12, 2012 5:53 AM -
Help with outer joins? NVL?
HI,
I have two reports I am creating, one for October and one for november.
The query is below so you can see what I am trying to do. There is a difference of about two hundred accounts, I want to see which accounts were in October and not in November. How can I view the different accounts and list them along side the november accounts or if this can't be done, how can I at least see the accounts which differ between the months? I am thinking that I need to build one report as an inline-view in the from clause, and then do an outerjoin on that aliased table, but am not sure on the syntax. Also, how can I use the NVL function to put in a value for the NULL columns?
select d.month,
a.account_no,
x.first_name||', '||x.last_name,
d.product,
d.cycle_forward ,
d.overusage,
d.logins,
d.seconds/3600 hours
from brio_broadcast.monthly_dial_revenue d,
pin.account_nameinfo_t x,
pin.account_t a
where month = '2002-10'
and a.POID_ID0 = d.ACCOUNT_OBJ_ID0
and a.poid_id0 = x.obj_id0
order by a.account_no;SELECT o.month,
o.account_no,
o.name,
o.product,
o.cycle_forward,
o.overusage,
o.logins,
o.hours
FROM (SELECT d.month,
a.account_no,
x.first_name || ', ' || x.last_name AS name,
d.product,
d.cycle_forward ,
d.overusage,
d.logins,
d.seconds / 3600 hours
FROM brio_broadcast.monthly_dial_revenue d,
pin.account_nameinfo_t x,
pin.account_t a
WHERE d.month = '2002-11'
AND a.poid_id0 = d.account_obj_id0
AND a.poid_id0 = x.obj_id0) n,
(SELECT d.month,
a.account_no,
x.first_name || ', ' || x.last_name AS name,
d.product,
d.cycle_forward ,
d.overusage,
d.logins,
d.seconds / 3600 hours
FROM brio_broadcast.monthly_dial_revenue d,
pin.account_nameinfo_t x,
pin.account_t a
WHERE d.month = '2002-10'
AND a.poid_id0 = d.account_obj_id0
AND a.poid_id0 = x.obj_id0) o
WHERE o.account_no = n.account_no (+)
AND n.account_no IS NULL
UNION ALL
SELECT n.month,
n.account_no,
n.name,
n.product,
n.cycle_forward,
n.overusage,
n.logins,
n.hours
FROM (SELECT d.month,
a.account_no,
x.first_name || ', ' || x.last_name AS name,
d.product,
d.cycle_forward ,
d.overusage,
d.logins,
d.seconds / 3600 hours
FROM brio_broadcast.monthly_dial_revenue d,
pin.account_nameinfo_t x,
pin.account_t a
WHERE d.month = '2002-10'
AND a.poid_id0 = d.account_obj_id0
AND a.poid_id0 = x.obj_id0) o,
(SELECT d.month,
a.account_no,
x.first_name || ', ' || x.last_name AS name,
d.product,
d.cycle_forward ,
d.overusage,
d.logins,
d.seconds / 3600 hours
FROM brio_broadcast.monthly_dial_revenue d,
pin.account_nameinfo_t x,
pin.account_t a
WHERE d.month = '2002-11'
AND a.poid_id0 = d.account_obj_id0
AND a.poid_id0 = x.obj_id0) n
WHERE n.account_no = o.account_no (+)
AND o.account_no IS NULL
ORDER BY 2 -
Help requried with outer joins
Hi All,
I neeed a query help can any one please help me getting this done,
for the below query
select trunc(assumed_time_sql) AS date1,sum(rp.rebate_due)as sum1 from mn_date_dim dd ,mn_rebate_payment rp,mn_prc_program prc,mn_structured_doc sd
where trunc(assumed_time_sql) in (TO_DATE('01-JUL-10','dd-mon-yy'),add_months(TO_DATE('01-JUL-10','dd-mon-yy'),-3),add_months(TO_DATE('01-JUL-10','dd-mon-yy'),-6),add_months(TO_DATE('01-JUL-10','dd-mon-yy'),-9))----input parameter
AND trunc(dd.assumed_time_sql)=TRUNC(rp.start_date)
AND prc.prc_program_id=rp.tiered_rebate_id
AND sd.struct_doc_id=prc.struct_doc_id
AND sd.struct_doc_id_num='M0000763'----input parameter
group by trunc(assumed_time_sql);
I am getting output as
date1 sum1
01-JAN-10 10
01-APR-10 15
01-JUL-10 20
But i want my output to be as
date1 sum1
01-JAN-10 10
01-APR-10 15
01-JUL-10 20
01-OCT-09 NULL
I have tried with outer joins but this didn't help me
Can any one please give me help in getting this done
ThanksHi,
As SB pointed out, you'd better provide tables and data in order to be helped more efficiently.
Anyway, you may want to investigate the use of NVL and/or DECODE so that you can translate NULL into valid values so they are returned to your select statement.
HTH,
Thierry
Handle: p78
Status Level: Newbie (10)
Registered: Mar 9, 2009
Total Posts: 60
Total Questions: 35 (30 unresolved) Be kind to share your helpful / correct threads with other with marking them as ANSWERED
Edited by: Urgent-IT on Feb 13, 2011 11:00 AM -
How to use OUTER JOIN in Oracle Answers Filters?
Hi, I need to have a filter on an 'Oracle Answers' report.
The query from the NQQuery.log appears as below. (I have simplified the SELECT clause here for easy reading)
SELECT t692.enquiry_business_route AS c1,
t692.enquiry_id AS c11, t913.YEAR AS c12,
t913.full_date AS c13, t666.surname AS c14,
t666.post_code AS c15, t855.company_name AS c16,
t983.notes AS c30
FROM
mkt_dw_enev_enhi_dim t983,
mkt_dw_key_partner_dim t855,
mkt_dw_event_type_dim t821,
mkt_dw_customer_dim t666,
mkt_dw_time_dim t913,
mkt_dw_enquiry_event_fact t692
WHERE (
t692.enquiry_id = t983.enqu_id
AND t666.customer_dim_key = t692.customer_dim_key
AND t692.event_date_time_key = t913.time_dim_key
AND TRUNC(t983.event_date)= t913.FULL_DATE
AND t692.event_type = t821.event_type_dim_key
AND t692.key_partner_dim_key = t855.key_partner_dim_key
AND t821.event_type_category = 'RECEIVE_FEE'
AND t913.YEAR = 2009
and t692.enquiry_id = 535986
For the following two lines I would like to have the OUTER JOIN.
AND t692.event_type = t821.event_type_dim_key(+)
AND t821.event_type_category(+) = 'RECEIVE_FEE' (THIS IS THE FILTER CONDITION, AT THE MOMENT IT DOESN'T WORK WITH OUTER JOIN SYMBOL)
Please could you let me know the best way of achieving the above.
Thanks
SrikanthIn the BMM layer in the join condition you will be able to specify the join to be (left, right or full outer join).
You can even add the required table in the LTS(logical table source) and also specify a left, right or full outer join there as well.
There is an interesting work around as mentioned in the below blog to get to the Outer join results with out changing anything in rpd but in Answers.
http://obiee101.blogspot.com/2008/11/obiee-outerjoin-workaround.html
Hope it helps
Thanks
prash -
Update with Outer Join, round 2
Thanks for those of you who helped me out on the first one (I never thought that you could use a one-row SELECT like that).
However, here is a new version of my problem:
I have three tables.
Table_1 has a column that needs to be updated based on values in Table_2 and Table_3.
Both Table_1 and Table_2 have values used to determine which Table_3 row to use.
However, not every Table_1 row has a corresponding Table_3 row, in which case the Table_3 value to use is assumed to be 1.
The tables and corresponding columns are:
TABLE_1
value_1 - the value to be updated
key_2 - a pointer to TABLE_2
key_3a - a pointer to TABLE_3, or a dummy value if there is no corresponding TABLE_3 record
TABLE_2
key_2 - the primary key
key_3b - a secondary pointer to TABLE_3
value_2 - a value to be used in calculating TABLE_1.value_1
TABLE_3
key_3a - the first part of the unique key
ley_3b - the second part of the unique key
value_3 - a value to be used in calculating TABLE_1.value_1
If there is a row in table_3 that matches the table_1.key_3a and table_2.key_3b values (where table_2.key_2 = table_1.key_2):
set table_1.value_1 = table_2.value_2 * table_3.value_3
If there is no such row in table_3:
set table_1.value_1 = table_2.value_2
I want to do something like this:
UPDATE table_1 t1
SET value_1 =
SELECT t2.value_2 * NVL(t3.value_3, 1)
FROM table_2 t2
LEFT JOIN table_3 t3
ON (t3.key_3b = t2.key_3b and t3.key_3a = t1.key_3a)
WHERE t2.key_2 = t1.key_2
However, Oracle does not allow t1 to be referenced in the ON clause of the outer join.
(Assume that every key_2 value in table_1 is in table_2 as well - it is only the key_3 value that can be a dummy.)
If I move "t3.key_3 = t1.key_3" to the WHERE clause, then t1.value_1 is null for rows without the corresponding table_3 value.
I can do it with a clone of table_1 using ROWIDs:
UPDATE table_1 t1
SET value_1 =
SELECT t2.value_2 * NVL(t3.value_3, 1)
FROM table_1 t1a
JOIN table_2 t2
ON t2.key_2 = t1a.key_2
LEFT JOIN table_3 t3
ON (t3.key_3b = t2.key_3b and t3.key_3a = t1a.key_3a)
WHERE t1a.row_id = t1.row_id
However, is there an easier way to do this using ANSI joins (i.e. without (+) syntax)?
I have this feeling I am missing something reasonably obvious here.ddelgran wrote:
Thanks for those of you who helped me out on the first one (I never thought that you could use a one-row SELECT like that).
I want to do something like this:
UPDATE table_1 t1
SET value_1 =
SELECT t2.value_2 * NVL(t3.value_3, 1)
FROM table_2 t2
LEFT JOIN table_3 t3
ON (t3.key_3b = t2.key_3b and t3.key_3a = t1.key_3a)
WHERE t2.key_2 = t1.key_2
However, Oracle does not allow t1 to be referenced in the ON clause of the outer join.
(Assume that every key_2 value in table_1 is in table_2 as well - it is only the key_3 value that can be a dummy.)
If I move "t3.key_3 = t1.key_3" to the WHERE clause, then t1.value_1 is null for rows without the corresponding table_3 value.
I can do it with a clone of table_1 using ROWIDs:
UPDATE table_1 t1
SET value_1 =
SELECT t2.value_2 * NVL(t3.value_3, 1)
FROM table_1 t1a
JOIN table_2 t2
ON t2.key_2 = t1a.key_2
LEFT JOIN table_3 t3
ON (t3.key_3b = t2.key_3b and t3.key_3a = t1a.key_3a)
WHERE t1a.row_id = t1.row_id
However, is there an easier way to do this using ANSI joins (i.e. without (+) syntax)?
I have this feeling I am missing something reasonably obvious here.You might want to refer to my post in your original thread how to use join views in updates. You can use ANSI join syntax there, too:
Re: Update with Outer Join
You would end up with something like this (note: untested):
UPDATE
SELECT t1.value_1, t2.value_2 * NVL(t3.value_3, 1) as new_val
FROM table_1 t1
INNER JOIN table_2 t2 ON (t2.key_2 = t1.key_2)
LEFT JOIN table_3 t3
ON (t3.key_3b = t2.key_3b and t3.key_3a = t1.key_3a)
SET value_1 = new_val;And again the same restrictions regarding key-preserved tables apply as described in the post referred to.
Regards,
Randolf
Oracle related stuff blog:
http://oracle-randolf.blogspot.com/
SQLTools++ for Oracle (Open source Oracle GUI for Windows):
http://www.sqltools-plusplus.org:7676/
http://sourceforge.net/projects/sqlt-pp/ -
Group by sum doesn't work with outer join. Can anyone please help me to get it right?
I've posted some sample data and queries below:
CREATE TABLE COMPLAINT
CNO NUMBER,
REASON VARCHAR2(15 BYTE),
TOTAL NUMBER
Insert into COMPLAINT
(CNO, REASON, TOTAL)
Values
(1, 'edge', 250);
Insert into COMPLAINT
(CNO, REASON, TOTAL)
Values
(2, 'edge', 250);
Insert into COMPLAINT
(CNO, REASON, TOTAL)
Values
(3, 'brst', 300);
Insert into COMPLAINT
(CNO, REASON, TOTAL)
Values
(4, 'crea', 400);
COMMIT;
CREATE TABLE SCOTT.COMPLAINTROLL
CNO NUMBER,
ROLL VARCHAR2(15 BYTE)
SET DEFINE OFF;
Insert into COMPLAINTROLL
(CNO, ROLL)
Values
(2, 'roll22');
Insert into COMPLAINTROLL
(CNO, ROLL)
Values
(1, 'roll4');
Insert into COMPLAINTROLL
(CNO, ROLL)
Values
(1, 'roll3');
Insert into COMPLAINTROLL
(CNO, ROLL)
Values
(1, 'roll2');
Insert into COMPLAINTROLL
(CNO, ROLL)
Values
(1, 'roll1');
COMMIT;
select * from complaint
CNO REASON TOTAL
1 edge 250
2 edge 250
3 brst 300
4 crea 400
select * from complaintroll
CNO ROLL
1 roll1
1 roll2
1 roll3
1 roll4
2 roll22
-- total of reason code edge is 500
select reason,sum(total)
from complaint c
group by reason
REASON SUM(TOTAL)
brst 300
crea 400
edge 500
-- total of reason code edge after outer join is 1250
select reason,sum(total)
from complaint c,complaintroll cr
where c.cno=cr.cno(+)
group by reason
REASON SUM(TOTAL)
brst 300
crea 400
edge 1250
{\code}
Thanks for reading this post.The problem that you described is simple. The outer join duplicates all the rows from the parent table (complaint). If you want to sum a column from the parent table, then this sum includes all the duplicated rows.
There are several solutions for this problem.
A) One had been shown already by Cenutil. Instead of doing an outer join, you can do a subquery in the select clause that delivers the additional information from the detail table.
SQL> select reason,
sum(total),
sum((select count(*) from complaintroll cr where c.cno=cr.cno)) cnt_rolls
from complaint c
group by c.reason;
REASON SUM(TOTAL) CNT_ROLLS
crea 400 0
brst 300 0
edge 500 5b) sum in two steps. First sum and count including the join criteria, then use this information to calculate the correct total sum.
SQL> select reason, sum(stotal), sum(stotal/scount), sum(scount), sum(cnt_rolls)
2 from (select reason, sum(total) stotal, count(*) scount, count(cr.cno) cnt_rolls
3 from complaint c
4 left join complaintroll cr on c.cno=cr.cno
5 group by reason, c.cno
6 )
7 group by reason;
REASON SUM(STOTAL) SUM(STOTAL/SCOUNT) SUM(SCOUNT) SUM(CNT_ROLLS)
crea 400 400 1 0
brst 300 300 1 0
edge 1250 500 5 5
sql> c) another option is to do the left join, but do the aggregation only one time for the parent table. Analytic functions are helpful for that. However since analytic fuinctions can't be used inside an aggregation function, we would again need an inline view.
SQL> select reason, sum(case when rn = 1 then total end) sum_total, count(*), count(crcno)
2 from (select row_number() over (partition by c.reason order by c.cno) rn,
3 c.*, cr.cno crcno
4 from complaint c
5 left join complaintroll cr on c.cno=cr.cno
6 )
7 group by reason;
REASON SUM_TOTAL COUNT(*) COUNT(CRCNO)
brst 300 1 0
crea 400 1 0
edge 250 5 5
SQL> Edited by: Sven W. on Feb 10, 2011 1:00 PM - formatting + column added to 2nd option -
Getting an error called Invalid relational Operator
SELECT DISTINCT t1.recv_order_no, t2.reference_no
FROM receiving_order t1, receiver_num t2
WHERE TRIM(t2.reference_no) (+) = TRIM (t1.recv_order_no)
ORDER BY t2.reference_no ASC
What I am doing wrong here ?
Can I use trim fun with outer join ?
Thanks for help.
SriniHi Srini,
I have done this with emp and dept
Following is an example:
1 select a.deptno, b.ename
2 from dept a, emp b
3* where trim(a.deptno) = trim(b.deptno(+))
scott>/
DEPTNO ENAME
10 CLARK
10 KING
10 GHULAM
10 MILLER
20 SMITH
20 ADAMS
20 FORD
20 SCOTT
20 JONES
30 ALLEN
30 BLAKE
30 MARTIN
30 JAMES
30 TURNER
30 WARD
40Hope this helps
Ghulam -
How to use common object from two tables with out join.
HI,
I have two tables called A & B In A table i have the following objects
1.weekend
2.S1(measure)
3.S2(measure)
4.S3(measure)
5.S4(measure)
And In B table i have followning columns
1.week end
2.p1(measure)
3.p2(measure)
4.p3(measure)
5.p4(measure)
Now in universe i created all the measure objects i.e.s1,s2,s3,s4,p1,p2,p3,p4 A.weekend,B.weekend.
instead of using week end two times i wnt to use only once because this is common in both table.
if i use join between these tables i am getting values fine
But With out join is there any thing to do in universe level to create common objects to use from both the tables..I tried using aggregate awareness but while reporting it is taking as two SQL.which is not synchronized.
Please help me on this ...hi,
Although Weekend column is present in both tables, by creating a single Object in Universe, Universe can identify relationship with only table referenced in Object Creation.
So, there will be no identification of relationship with other table measures.
Obviously, you need to create 2 Weekend objects in Universe (in two classes).
Case 1: You need not join these two tables in Universe. When you create 2 Queries in WEBI, automatcially Weekend objects are synchronized (if both are of same datatype)
Case 2: If you join these two tables in Universe, Obviously,
your SQL may contain Weekend from Table1, measures from Table 2
or
your SQL may contain Weekend from Table2, measures from Table 1
Finally, You need to create 2 objects in Universe. But your query may contain a single Object based on Case 2.
Regards,
Vamsee -
here is the query with Four tables as outer joins
select A.student, B.race, B.sex, B.bdate, trunc(C.cdate-B.bdate)/365.25) "age",
A.randomno, A.randomdt, min(D.vdate), max(D.vdate) E.tdate, E.termrsn
from case A, hist B, ent C, log D, ter E
where A.randomno > 0
and A.del IS NULL
and B.del IS NULL
and B.ndone IS NULL
and B.seq = 0.02
and C.del IS NULL
and c.ndone IS NULL
and D.del IS NULL
and D.ndone IS NULL
and E.del IS NULL
and E.ndoe IS NULL
and average > 0
and (B.student = A.student (+))
and (C.student = A.student (+))
and (E.student = A.student (+))
and (D.student = A.student (+))
group by A.student, B.race, B.sex, B.bdate, trunc(c.cdate-b.bdate)/365.25), A.randomno,
A.randomdt , E.vdate, E.termrsn
=============================================
next query with outer joins but with subqueries in the from clause
select A.student, B.race, B.sex, B.bdate, trunc(C.cdate-B.bdate)/365.25) "age",
A.randomno, A.randomdt, min(D.vdate), max(D.vdate) E.tdate, E.termrsn
from A,
(select race, sex, bdate, student from hist
where del IS NULL and ndone IS NULL and seq = 0.02) B,
(Selcet cdate, student from ent
where del IS NULL and ndone IS NULL ) C,
(Select vdate, student from log
where del IS NULL and ndone IS NULL and average > 0) D,
(Select vdate, termrsn, student from ter
where del IS NULL and ndone IS NULL ) E
(where A.randno >0) and A.del IS NULL
and (A.student = B.Student (+))
and (A.student = C.Student (+))
and (A.student = E.Student (+))
and (A.student = D.Student (+))
group by A.student, B.race, B.sex, B.bdate, trunc(c.cdate-b.bdate)/365.25), A.randomno,
A.randomdt , E.vdate, E.termrsn
This two queries runs fine....but the second query gives correct records(WHICH IS WHAT I AM EXPECTING)
The previous query gives 4 records less.
Does Oracle support outer joins with out subquerys in the from clause or i am doing some thing wrong here(I mean syntax error)
DO I need to write subqueries for every outer join to get the correct record.
If I do outer joins with one or two tables with out subqueries.....I do not have any problem
Thanks
Rama
nullThere are two issues. First Oracle supports outer joins against one table. This means you can do this:
where a.col1 = b.col1(+)
and a.col2 = c.col2(+)
and a.col3 = d.col3(+)
but you can't do this:
where a.col1 = b.col1(+)
and b.col2 = c.col2(+)
because this outer joins to more than one table.
The second issue is that you must outer join to all columns of a table. So you can't do this:
where a.col1 = b.col1(+)
and b.col2 is null
but you can do this:
where a.col1 = b.col1(+)
and 'X' = nvl( b.col2(+), 'X' )
null -
How to poll a blob using db adapter, with outer joins condition
Hi All,
We are trying to poll tables which contain column types as long and blob, we are using relationships in adapter and kept outer joins. by this we got select distinct t1.document .....etc
distinct keyword cannot be used for blobs.
is there any way to poll these tables having blob column types with outer joins.
thanks a lot in advance,
RRHi,
Procedure will be an explicit Invoke not Polling. If you can alter you design such that your BPEL process instead of polling gets triggered by some external entity (Java, PL/SQL, Scheduler, another BPEL etc.), you can put the data fetching logic in the procedure and call this procedure from your BPEL process to get the data. And your BPEL process is called periodically at an interval by an external entity.
Also see if you can restrict the duplicate records at the database level itself. Polling, AFAIK, is limited in terms of customization and wouldn't be easy to customize. However, would like to learn a way if someone has.
Regards,
Neeraj Sehgal -
Generate a where clause with outer join criteria condition: (+)=
Hi,
In my search page, I use Auto Customization Criteria mode, and I build where clause by using get Criteria():
public void initSrpQuery(Dictionary[] dic, String userName) {
int dicSize = dic.length;
StringBuffer whereClause = new StringBuffer(100);
Vector parameters = new Vector(5);
int clauseCount = 0;
int bindCount = 1;
for(int i=0; i < dicSize; i++){
String itemName = (String)(dic.get(OAViewObject.CRITERIA_ITEM_NAME));
Object value = dic[i].get(OAViewObject.CRITERIA_VALUE);
String joinCondition = (String)dic[i].get(OAViewObject.CRITERIA_JOIN_CONDITION);
String criteriaCondition = (String)dic[i].get(OAViewObject.CRITERIA_CONDITION);
String criteriaDataType = (String)dic[i].get(OAViewObject.CRITERIA_DATATYPE);
String viewAttributename = (String)dic[i].get(OAViewObject.CRITERIA_VIEW_ATTRIBUTE_NAME);
String columnName = findAttributeDef(viewAttributename).getColumnNameForQuery();
if((value != null) /*&& (!("".equals((String).trim())))*/){
if(clauseCount > 0){
whereClause.append(" AND ");
whereClause.append(columnName + " " + criteriaCondition + " :");
whereClause.append(++bindCount);
parameters.addElement(value);
clauseCount++;
If I want to generate following where clause:
select
,emp.name
,emp.email
,emp.salesrep_number
,comp.name
,gs.srp_goal_header_id
,gs.status_code
,gs.start_date
,gs.end_date
from g2c_goal_shr_emp_assignments_v emp
,jtf_rs_salesreps rs
,xxg2c_srp_goal_headers_all gs
,cn_comp_plans_all comp
where 1 = 1
and rs.salesrep_id = gs.salesrep_id (+)
and gs.comp_plan_id = comp.comp_plan_id (+)
and gs.period_year (+) = :1 -- :1 p_fiscal_year
How can I generate a where clause with outer join : gs.period_year (+) = :1 ? Will I get '(+)=' from get(OAViewObject.CRITERIA_CONDITION)?
thanks
LeiIf you are using SQL-Plus or Reports you can use lexical parameters like:
SELECT * FROM emp &condition;
When you run the query it will ask for value of condition and you can enter what every you want. Here is a really fun query:
SELECT &columns FROM &tables &condition;
But if you are using Forms. Then you have to change the condition by SET_BLOCK_PROPERTY.
Best of luck! -
Oracle.jbo.RowAlreadyDeletedException with outer join
Hi,
I have created a VO, based on an EO, with an outer join present.
The first time I query my data (search) everything goes well, but when I perform a search the second time, I receive the error message: "oracle.apps.fnd.framework.OAException: oracle.jbo.RowAlreadyDeletedException: JBO-25019: Entiteitsrij van sleutel oracle.jbo.Key[202 53162 ] not found in XxpostMmpParametersEO."
The reason why is because of the outer join there is no 1 to 1 relationship between the EO and the VO. However for the first time , it works fine.
Does someone have an idea how I can avoid the error for my second search action?
Thanks in advance!
br
GuyHi all,
the following article:
http://radio.weblogs.com/0123729/stories/2003/05/15/entityObjectOverTableWhosePrimaryKeyMayBeNull.html
suggest a possible workaround. It wok fine, but it is not generic! :((
By
Alessandro
Maybe you are looking for
-
Even when I start firefox I have to sit here and wait for it to tell me a script on this page is not responding or has quit working. Once that happens which takes a while, I can say stop script and it moves on. I've always liked using firefox and hav
-
When I render a video in photoshop, the video contains unwanted text
The text at the bottom looks like thismy export settings look like this, what am i doing to make that unwanted text appear in my mp4 video file?
-
Populating combobox in jsp page from javabean using jsp:getProperty tag
hi, i am new to jsp, so i don;t know how to populate a combobox in jsp page with productid attribute from a javabean called Bid . i want to have a code to automatically populating combobox using the attribute value from javabean. please reply me. <js
-
Filtering my DataGridView with Combo Boxes
Hello everyone! I have recently started working with windows form application and I must say it is really awsome! I have came up with a project but I came across a little problem and I hope some of you might help me! I have established a local databa
-
Is any of this actionable? What should I try next? Exit Code: 7 Please see specific errors and warnings below for troubleshooting. For example, ERROR: DW030, DW050 ... -------------------------------------- Summary ---------------------------------