sql join question [message #23329] |
Mon, 02 December 2002 17:52 |
ravi_kiran99
Messages: 8 Registered: December 2002
|
Junior Member |
|
|
Hi,
I need help with a sql (self join) query. Thanks for all your help.
A table T1 has columns C1,C2,C3
I want to perform a query to get all the rows where value of C2 is equal to someother value of C2 in a different row in the same table and C3='N'
C1 C2 C3
sam 100 Y
tom 200 N
john 300 N
sam 100 N
I want to be able to select the 4th row from the above data because for this row (value of C2 is same as value of C2 in the first row and C3=N )
|
|
|
Re: sql join question [message #23330 is a reply to message #23329] |
Mon, 02 December 2002 18:18 |
Amit Chauhan
Messages: 74 Registered: July 1999
|
Member |
|
|
Hi
Try this :
select * from temp;
C1 C2 C3
----- ---- ---
sam 100 Y
tom 200 N
john 300 N
sam 100 N
select * from temp a
where 1 < (select count(*) from temp
where a.c2 = c2)
and c3 = 'N'
Hope that helps
Thanks
Amit
|
|
|
|