SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Function help
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

joep92
Starting Member

1 Posts

Posted - 04/09/2012 :  11:45:55  Show Profile  Reply with Quote
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 15


how 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

India
48076 Posts

Posted - 04/09/2012 :  11:48:07  Show Profile  Reply with Quote
A simple group by will do the trick!

SELECT TERRITORYID,COUNT(SALESPERSONID) AS SalesPersonCnt
FROM Table
GROUP BY TERRITORYID


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000