示例地址表
ID, EmployeeID, Address
1, 100, TownA
2, 200, TownA
3, 300, TownB
如何为每个唯一地址返回所有雇员的计数?
e.g
EmployeeCount, Address
2 TownA
1, TownB
答案 0 :(得分:1)
你应该按照这一点做点什么。
SELECT count(EmployeeID) as EmployeeCount, Address FROM table GROUP BY Address
答案 1 :(得分:0)
这是一个简单的分组
SELECT Count(*) EmployeeCount, Address
FROM yourTable
GROUP BY Address