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
 Sum Unduplicated Data in columns

Author  Topic 

huynhtl
Posting Yak Master

107 Posts

Posted - 2008-09-17 : 10:43:51
Hi,
quick question. Is there a way to sum unduplicated data?

i.e.
column 1 - clients
column 2 - type ( in this type, there are b=blue,g=green,r=red and p=pink)

clients can chose all b/g/r/p or just p or just g or just r or just b or b/g or b/r or b/p, etc.,etc.

So, if clients chose those combination, I want to sum clients one time regardless what they pick. The delima i have right now, is when I sum up total, it will add up all the combination that clients chose.

another example:
clients pick b/g/r/p would equal 1 client with four color
result I want:
1 client not 4 client

hope this is not too confusing

Thanks

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2008-09-17 : 10:49:47
select Count(distinct clientID)
from yourtable
where ....

be sure to read this article:

http://www.sqlteam.com/article/how-to-use-group-by-in-sql-server

and also part II, for info on all this.

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page
   

- Advertisement -