-
Select statement help
I have a question:
If I have two tables in Oracle, say T1 and T2, and they have the following properties:
Code:
T1
c1 c2 c3
______________
| A | 1 | alpha|
| B | 2 | beta |
| C | 3 | zeta |
T2
c1 c2 c4
_____________
| B | 2 | doh |
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.
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:
Code:
Select ...
c1 c2 c3 c4
____________________
| A | 1 | alpha| null|
| B | 2 | beta | doh |
| C | 3 | zeta | null|
Thanks in advance!
-
Code:
SELECT t1.c1, t1.c2, t1.c3, NVL(t2.c4, 'null') c4
FROM t1
LEFT OUTER JOIN t2
ON t1.c1 = t2.c1
AND t1.c2 = t2.c2;
Is this what your teacher wanted???
-
Actually, it's for my work... but thanks though!
-
Originally Posted by gandolf989
Code:
SELECT t1.c1, t1.c2, t1.c3, NVL(t2.c4, 'null') c4
FROM t1
LEFT OUTER JOIN t2
ON t1.c1 = t2.c1
AND t1.c2 = t2.c2;
Is this what your teacher wanted???
LOL!!
Jeff Hunter
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|