Sql Distinct Count of resulting table with no conditionals
Posted
by AfterImage
on Stack Overflow
See other posts from Stack Overflow
or by AfterImage
Published on 2010-03-24T13:56:12Z
Indexed on
2010/03/24
14:13 UTC
Read the original article
Hit count: 222
sql
Hello everyone,
I want to count the number of accounts from the resulting table generated from this code. This way, I know how many people liked blue at one time.
Select Distinct PEOPLE.FullName, PEOPLE.FavColor From PEOPLE
Where FavColor='Blue'
Lets say this is a history accounting of what people said their favorite color when they were asked so there may be multiple records of the same full name if asked again at a much later time; hence the distinct.
The code I used may not be reusable in your answer so feel free to use what you think can work. I am sure I found a possible solution to my problem using declare and if statements but I lost that page... so I am left with no solution. However, I think there is a way to do it without using conditionals which is what I am asking and rather have. Thanks.
Edit: My question is: From the code above, is there a way to count the number of accounts in the resulting table?
© Stack Overflow or respective owner