Sql Query Help in select statement/Oracle Discoverer
I have a table as follows.
Id Code Indicator
1 AB
1 CD Y
1 开发者_StackOverflow EF
2 BC Y
3 AB
4 GH
4 AB Y
5 CD
5 BC
Now I need to retrieve the ID's which do not have any indicator associated to them. In this case, the retrieved rows should be
ID Code Indicator
3 AB
5 CD
5 BC
Thanks to y'll I got it in sql but I have the same table as a view in Oracle discoverer. How do i write a report to get the same result?All help much appreciated!!
This should do it (Warning: Untested):
select id, code
from table
where id not in (select id from table where indicator='Y')
SELECT *
FROM TABLE t1
WHERE T1.ID in (SELECT
t2.ID
FROM Table t2
GROUP BY t2.ID
HAVING MAX(t2.Indicator) = 'Y')
精彩评论