1

我正在尝试按大多数点对表格进行排序,然后按字母顺序排列。我已经做到了这一点,但我无法让它发挥作用。

SELECT category FROM (
SELECT category from table ORDER BY points DESC LIMIT 35
) a
ORDER a.by category LIKE 'A%'

我究竟做错了什么?

谢谢

4

3 回答 3

2

您需要使用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
于 2012-09-07T18:37:36.893 回答
0

您可以在单个中按多列排序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
于 2012-09-07T18:37:56.380 回答
0

您只需要以下内容:

SELECT category FROM table ORDER BY points DESC, category ASC Limit 35
于 2012-09-07T18:39:33.073 回答