我正在尝试按大多数点对表格进行排序,然后按字母顺序排列。我已经做到了这一点,但我无法让它发挥作用。
SELECT category FROM (
SELECT category from table ORDER BY points DESC LIMIT 35
) a
ORDER a.by category LIKE 'A%'
我究竟做错了什么?
谢谢
我正在尝试按大多数点对表格进行排序,然后按字母顺序排列。我已经做到了这一点,但我无法让它发挥作用。
SELECT category FROM (
SELECT category from table ORDER BY points DESC LIMIT 35
) a
ORDER a.by category LIKE 'A%'
我究竟做错了什么?
谢谢
您需要使用WHERE
:
SELECT a.category
FROM (
SELECT category FROM `table` ORDER BY points DESC LIMIT 35) a
WHERE a.category LIKE 'A%'
ORDER BY a.category
更新
OP想要一个简单的ORDER BY
SELECT a.category
FROM (
SELECT category FROM `table` ORDER BY points DESC LIMIT 35) a
ORDER BY a.category
您可以在单个中按多列排序ORDER BY
SELECT category FROM table
ORDER BY points DESC, category ASC
LIMIT 35
如果您希望按字母顺序订购前 35 点(不考虑前 35 名中的顺序),您可以执行以下操作:
SELECT a.category
FROM
(SELECT category FROM table ORDER BY points LIMIT 35) AS a
ORDER BY a.category ASC
您只需要以下内容:
SELECT category FROM table ORDER BY points DESC, category ASC Limit 35