Need Oracle sql to list records where for a key, specific value is paired with other values -


i have data in table tab :

dept    role -------------     100     sell 101 admin 102 admin 102 staff 103 admin 103 staff 103 sell 104 frq 104 staff 104 sell 105 admin 105 int 105 sell 

i need list depts admin appearing @ least 1 other role not admin alone or not other dept admin not present. example : 102, 103,105 desired results 100,101,104 filtered out.

could please assist me in ?

thanks in advance.

select distinct yt.dept   your_table yt        join          your_table adm on adm.dept = yt.dept  adm.role = 'admin' ,    yt.role != 'admin' 

basically used inner join filter depts having no 'admin' roles , filtered 'admin' roles resultset.


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -