atultiwari.eng06 (9/17/2014)
Tablename Consumer:ID Resource
119319004 RG
119319004 MI
119319005 RG
119319005 MI
119319005 BT
119319006 RG
I want id whose Resource is only RG and MI that's(119319004)
Output
119319004
Please reply..
Could you do something like:
with cte1 as (select id, count(*) from mtable where mtable.resource in ('rg', 'mi')
group by id having count(*) = 2)
select id
from mtable
inner join cte1 on mtable.id = cte1.id ;
I know this may or may not work for you as written but maybe it will give you an idea.