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 |
|
satheesh
Posting Yak Master
152 Posts |
Posted - 2011-05-05 : 05:58:33
|
| Dear AllI have agentid,agentname and customerid in a cst table There are many different agent. So my table contains around 1000 unique agentid and agent nameNow i want to count how many customer comes through each agentie the result beagnetid agentname Total100 XXX 2345(total customer comes through this agent xxx)200 YYY 100How to do this individual count in a single query?Any help would be highly appreicatedRegards,SG select count(customerid) from cst gives total like (2445) but i need to find by each agent.Regards,SG |
|
|
lionofdezert
Aged Yak Warrior
885 Posts |
Posted - 2011-05-05 : 06:02:53
|
| SELECT agentid, agentname, COUNT(customerid) AS AgentCustomersCountGROUP BY agentid, agentname--------------------------http://connectsql.blogspot.com/ |
 |
|
|
|
|
|