Order by COUNT per value

前端 未结 4 2090
时光说笑
时光说笑 2020-11-27 05:12

I have a table which stores IDs and the city where the store is located.

I want to list all the stores starting with the stores that are in the city where there are

4条回答
  •  醉梦人生
    2020-11-27 05:23

    SELECT count(City), City
    FROM table
    GROUP BY City
    ORDER BY count(City);
    

    OR

    SELECT count(City) as count, City
    FROM table
    GROUP BY City
    ORDER BY count;
    

    Ahh, sorry, I was misinterpreting your question. I believe Peter Langs answer was the correct one.

提交回复
热议问题