我有一个查询,我想从表中获取 20 个最受欢迎的位置,然后按字母顺序排列它们。我想知道是否有更清洁或更有效的方法来做到这一点?
SELECT
city
FROM (
SELECT
city,
count(*) AS cnt
FROM locations
GROUP BY city
ORDER BY cnt DESC
LIMIT 20
) s ORDER BY city;
我有一个查询,我想从表中获取 20 个最受欢迎的位置,然后按字母顺序排列它们。我想知道是否有更清洁或更有效的方法来做到这一点?
SELECT
city
FROM (
SELECT
city,
count(*) AS cnt
FROM locations
GROUP BY city
ORDER BY cnt DESC
LIMIT 20
) s ORDER BY city;