Home » SQL & PL/SQL » SQL & PL/SQL » sql join question
sql join question [message #23329] Mon, 02 December 2002 17:52 Go to next message
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 Go to previous messageGo to next message
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
Re: sql join question -Thanks [message #23331 is a reply to message #23329] Mon, 02 December 2002 19:55 Go to previous message
ravi_kiran99
Messages: 8
Registered: December 2002
Junior Member
Hi All
Thanks for your quick replies.
I got it working now with ur ideas.
Previous Topic: Cursor in SQL Plus
Next Topic: pl/sql very urgent
Goto Forum:
  


Current Time: Wed May 15 18:23:46 CDT 2024