Wednesday, March 5, 2008

Find if column_A value = 'X' and also = 'Y' in other rows of the table.

-- confirm that all users who have “FULL” sector access
-- also have “READ” sector access?
-- This query will list out any username that have FULL but not READ

select username, sector
from sectoraccess a
where sector = 'FULL'
and not exists (select 1 from tradingsectoraccess b
where b.username = a.username and b.tradingsector = 'READ')


--And now the oppersite
--Will list users that have FULL and READ.


select username, sector
from tsa a
where and a.sector in ('FULL','READ')
and exists (select 1 from tsa b
where b.tradingsector = 'FULL'
and b.username = tsa.username)
and exists (select 1 from tsa c
where c.tradingsector = 'READ'
and c.username = tsa.username)
order by 1

********************************************
keywords column equals different same
********************************************

1 comment:

Anonymous said...

Nice brief and this enter helped me alot in my college assignement. Say thank you you seeking your information.