-
Query
Hi Every one...
Please let me know how to write this query......
Lets say I have the following data in a table which has 3 columns..
X Y Ind
1 1 Y
2 1 N
3 1 Y
4 1 Y
5 2 Y
6 3 Y
I want to write a query to retrieve all the rows with ind = 'Y' and also the rows which do not have y values duplicated...Inthis case my query should retrieve...
5 2 Y
6 3 Y
X column is primary key.....How do I eliminate duplicates in Y column...
Appreciate your help...
Thanks....
-
Code:
select *
from my_table t1
where t1.ind = 'Y'
and not exists (select null
from my_table t2
where t2.y = t1.y
and t1.rowid != t2.rowid);
-