用于计算出现次数的MySQL函数

时间:2016-12-07 16:11:36

标签: mysql

所以我有一个包含以下列的表:id, Fname, Lname, city and desc

我想要完成的是创建一个计算每个城市有多少员工工作的功能。

通常我会使用类似的东西 select city, count(*) as NumofEmp from employee group by city 但目前我必须为此创建一个功能。我怎么能做到这一点?

1 个答案:

答案 0 :(得分:0)

select city, count(name) as NumofEmp from employee group by city