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.
| Author |
Topic |
|
SamC
White Water Yakist
3467 Posts |
Posted - 2002-06-07 : 14:04:53
|
| I've got a table of employees with a field called "office"I can count all users in an office usingSELECT COUNT(DISTINCT OFFICE) FROM USERSI can get a recordset of all the officesSELECT DISTINCT OFFICE FROM USERSSeems like a hybrid of the two statements could be constructed that will return a recordset of all the unique office names and the count of employees in each office?Thanks,Sam |
|
|
izaltsman
A custom title
1139 Posts |
Posted - 2002-06-07 : 14:18:55
|
| You need to take advantage of the GROUP BY clause (you are asking for a count of users, grouped by office)...SELECT OFFICE, COUNT(*) FROM USERS GROUP BY OFFICE |
 |
|
|
|
|
|