在我的SQL表中,我想找到出现超过300次的状态代码,以及包含每个相应状态代码的记录的总行数。我的SQL上有点生锈(再加上星期一早上8点......)这就是我到目前为止所做的:
SELECT StateCode
FROM ZipCodeTerritory
HAVING COUNT(StateCode) > 300
答案 0 :(得分:2)
SELECT StateCode, Count(*) As StateCodeCount
FROM ZipCodeTerritory
Group By StateCode
HAVING COUNT(*) > 300
答案 1 :(得分:1)
这样的东西?
SELECT StateCode, count(StateCode)
FROM ZipCodeTerritory
GROUP BY StateCode
HAVING COUNT(StateCode) > 300
答案 2 :(得分:0)
SELECT StateCode, count(*)
FROM ZipCodeTerritory
GROUP BY StateCode
HAVING count(*) > 300