Select statement help
I have a question:
If I have two tables in Oracle, say T1 and T2, and they have the following properties:
Now my problem: I want to have a single select statement such that it returns 4 columns, namely T1.c1, T1.c2, T1.c3, T2.c4. It should return all the rows from T1.
c1 c2 c3
| A | 1 | alpha|
| B | 2 | beta |
| C | 3 | zeta |
c1 c2 c4
| B | 2 | doh |
T2.c4 should return either null or its actual value from T2 if (T1.c1 = T2.c1 AND T1.c2 = T2.c2).
So the sample output of this select statement would be:
c1 c2 c3 c4
| A | 1 | alpha| null|
| B | 2 | beta | doh |
| C | 3 | zeta | null|
Thanks in advance!
Is this what your teacher wanted???
SELECT t1.c1, t1.c2, t1.c3, NVL(t2.c4, 'null') c4
LEFT OUTER JOIN t2
ON t1.c1 = t2.c1
AND t1.c2 = t2.c2;
this space intentionally left blank
Actually, it's for my work... but thanks though!
Originally Posted by gandolf989
Click Here to Expand Forum to Full Width