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 |
|
joep92
Starting Member
1 Post |
Posted - 2012-04-09 : 11:45:55
|
| SALESPERSONID SALESPERSONNAME TERRITORYID------------- ------------------------- ----------- 1 Doug Henny 2 8 Fred Flinstone 2 3 William Strong 3 9 Mary James 4 4 Julie Dawson 4 5 Jacob Winslow 5 2 Robert Lewis 13 6 Pepe Lepue 13 10 Mary Smithson 15how would I display the territory id and the amount of sales people that work in that territory. For example territory 2 should show 2 sales people working there |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-04-09 : 11:48:07
|
A simple group by will do the trick!SELECT TERRITORYID,COUNT(SALESPERSONID) AS SalesPersonCntFROM TableGROUP BY TERRITORYID ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|