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
 Other Forums
 MS Access
 Count(*) query

Author  Topic 

mystifier
Starting Member

12 Posts

Posted - 2012-03-03 : 13:59:11
Can anyone help a newbie with this query:

DATA
Client01, Status1
Client02, Status1
Client03, Status2
Client04, Status3
Client05, Status3
Client06, Status3

SELECT COUNT(*) FROM DATA WHERE Status = 'Status1'
would tell me how many clients were Status1 but I want a summary for each status

REQUIRED OUTPUT
CountOfStatus1(2), CountOfStatus2 (1), CountOfStatus3 (3)

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2012-03-03 : 17:29:56
SELECT Status, COUNT(*) FROM Data GROUP BY Status ORDER BY Status



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

mystifier
Starting Member

12 Posts

Posted - 2012-03-03 : 19:10:54
Perfect SwePeso,

Thank-you.
Go to Top of Page
   

- Advertisement -