我有读取计数只返回一行,但是如果你使用group by你可以得到多行返回
返回上述结果的代码是
SELECT event_id,COUNT(event_id)AS nr FROM
picks
GROUP BY event_id DESC LIMIT 0,30
但是我现在需要找到一种按DESC
顺序订购它的方法。我已经尝试了order by
,但后来只返回1行,看起来我不能将DESC
与group by一起使用。寻求建议
更新
以下是给我的结果,如下图所示
SELECT event_id, COUNT( event_id ) AS nr
FROM picks
GROUP BY event_id
Order by event_id DESC
LIMIT 0 , 30
答案 0 :(得分:0)
降序
SELECT event_id, COUNT( event_id ) AS nr
FROM picks
GROUP BY event_id
Order by event_id DESC
LIMIT 0 , 30
升序 //这是默认的排序顺序
SELECT event_id, COUNT( event_id ) AS nr
FROM picks
GROUP BY event_id
Order by event_id
LIMIT 0 , 30