Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Help

Author  Topic 

EMMERSON
Starting Member

3 Posts

Posted - 2014-11-11 : 10:10:48
I have a table called preferences

Fields in the
client
type
value

A client will exist multiple times, 3 different types and potentially 2 different values post and email will be the values.

If i wanted to know if a client had a post for one pref and email for the other how would i do it?.

Thanks

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2014-11-11 : 10:37:50
select client from (
select client,
count(case when type = 'email' then 1 end) as countemail,
count(case when type = 'post' then 1 end) as countpost
from preferences
) prefs
where countemail > 0 and countpost > 0
Go to Top of Page
   

- Advertisement -