1

在我的 SQL 表中,我想找到出现超过 300 次的状态代码,以及包含每个相应状态代码的记录的总行数。我的 SQL 有点生疏(加上星期一早上 8 点......),这就是我到目前为止所拥有的:

SELECT StateCode
FROM ZipCodeTerritory
HAVING COUNT(StateCode) > 300
4

3 回答 3

2
SELECT StateCode, Count(*) As StateCodeCount
FROM ZipCodeTerritory
Group By StateCode
HAVING COUNT(*) > 300
于 2013-10-14T15:20:42.077 回答
1

像这样的东西?

SELECT StateCode, count(StateCode)
FROM ZipCodeTerritory
GROUP BY StateCode
HAVING COUNT(StateCode) > 300
于 2013-10-14T15:21:20.563 回答
0
SELECT StateCode, count(*)
FROM ZipCodeTerritory
GROUP BY StateCode
HAVING count(*) > 300
于 2013-10-14T15:22:07.427 回答