Help needed in Left Outer Join in Db2
=====================================
Hi,
I am migrating Oracle SQL queries to Db2 queries. How do I write following Left outer join in db2.
1)
Oracle :
========
Select T1.COL1,
T2.COL1,
SUM(T2.COL2)
FROM T1,
( SELECT MAX(DAY) FROM CALENDAR) CALENDAR,
T2
WHERE T1.COL3 = CALENDAR.DAY AND
T1.COL4 = T2.COL4(+)
GROUP BY T1.COL1,T2.COL1
db2 : ???
=====
2)
Oracle :
========
Select A1.COL1,
A1.COL2,
A3.COL1,
A4.COL1
FROM
( Select T1.Col1 COL1,
SUM(T2.Col1) COL2
FROM T1,T2
WHERE T1.COL2 = T2.COL2(+)
GROUP BY T1.COL1 ) A1,
( SELECT MAX(DAY) FROM CALENDAR) CALENDAR,
( SELECT T3.COL1 AS COL1,
T4.COL2 AS COL2,
T3.COL2 AS COL3
FROM T3.COL5 = T4.COL5) A2,
A3
WHERE A1.COL1 = A2.COL1(+)
A2.COL3 = A3.COL3(+)
A2.COL4 = A3.COL4(+)
dB2 : ???
====
Thanks in advanced.
Bhavesh
=====================================
Hi,
I am migrating Oracle SQL queries to Db2 queries. How do I write following Left outer join in db2.
1)
Oracle :
========
Select T1.COL1,
T2.COL1,
SUM(T2.COL2)
FROM T1,
( SELECT MAX(DAY) FROM CALENDAR) CALENDAR,
T2
WHERE T1.COL3 = CALENDAR.DAY AND
T1.COL4 = T2.COL4(+)
GROUP BY T1.COL1,T2.COL1
db2 : ???
=====
2)
Oracle :
========
Select A1.COL1,
A1.COL2,
A3.COL1,
A4.COL1
FROM
( Select T1.Col1 COL1,
SUM(T2.Col1) COL2
FROM T1,T2
WHERE T1.COL2 = T2.COL2(+)
GROUP BY T1.COL1 ) A1,
( SELECT MAX(DAY) FROM CALENDAR) CALENDAR,
( SELECT T3.COL1 AS COL1,
T4.COL2 AS COL2,
T3.COL2 AS COL3
FROM T3.COL5 = T4.COL5) A2,
A3
WHERE A1.COL1 = A2.COL1(+)
A2.COL3 = A3.COL3(+)
A2.COL4 = A3.COL4(+)
dB2 : ???
====
Thanks in advanced.
Bhavesh