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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Counting Query - Part II

Author  Topic 

SamC
White Water Yakist

3467 Posts

Posted - 2002-06-09 : 21:28:56
I want to get a count of all users, and "completed" users by office.

select office, count(*) as total from users group by office

Gives me total users by office.

SELECT Office, COUNT(*) AS total FROM Users
WHERE (Completed = 1)GROUP BY Office

Give me the count of users by office who have completed.

Is there a single statement that'll give me both or do I need to join these two statements?

Thanks,

Sam

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-06-09 : 21:49:18
SELECT Office,
Sum(CASE Completed WHEN 1 THEN 1 ELSE 0 END) AS Completed,
Count(*) AS Total
FROM Users
GROUP BY Office


Go to Top of Page
   

- Advertisement -