mysql 中order by 与group by的顺序 是

select
from
where
group by
order by

 

注意:group by 比order by先执行,order by不会对group by 内部进行排序,如果group by后只有一条记录,那么order by 将无效。要查出group by中最大的或最小的某一字段使用 max或min函数。

例:

select sum(click_num) as totalnum,max(update_time) as update_time,count(*) as totalarticle from article_detail where userid =1 group by userid order by update_time desc

相关文章:

  • 2021-10-25
  • 2021-05-05
  • 2021-10-12
  • 2022-12-23
  • 2022-12-23
  • 2021-06-19
猜你喜欢
  • 2021-08-25
  • 2021-07-13
  • 2021-08-11
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案