开发者

Sql Query Help in select statement/Oracle Discoverer

开发者 https://www.devze.com 2023-04-06 17:28 出处:网络
I have a table as follows. IdCodeIndicator 1AB 1CDY 1开发者_StackOverflowEF 2BCY 3AB 4GH 4ABY 5CD 5BC Now I need to retrieve the ID\'s which do not have any indicator associated to them. In this c

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')
0

精彩评论

暂无评论...
验证码 换一张
取 消