gpt4 book ai didi

mysql count 以 DESC 顺序返回多行

转载 作者:行者123 更新时间:2023-11-29 03:31:17 25 4
gpt4 key购买 nike

我读过的计数只返回一行,但是如果你使用 group by 你可以得到多行返回

enter image description here

上面返回结果的代码是

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

enter image description here

最佳答案

降序

SELECT event_id, COUNT( event_id ) AS nr
FROM picks
GROUP BY event_id
Order by event_id DESC
LIMIT 0 , 30

enter image description here

升序 //这是默认的排序顺序

SELECT event_id, COUNT( event_id ) AS nr
FROM picks
GROUP BY event_id
Order by event_id
LIMIT 0 , 30

enter image description here

关于mysql count 以 DESC 顺序返回多行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30175975/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com