所以我知道如果我想要计算具有相同城市名称的条目数,我将使用以下代码:
SELECT *, COUNT(*) AS count
FROM location
GROUP BY city
ORDER BY count
DESC
如果我想计算具有相同城市名称和州名的条目数量,我该如何去做呢?
citynameA,stateNameB =具有相同cityname和statename的条目数
答案 0 :(得分:3)
您可以将多个字段与group by一起使用,例如
SELECT city, state, COUNT(*) AS count
FROM location
GROUP BY city, state
ORDER BY count
DESC