• notice
  • Congratulations on the launch of the Sought Tech site

In-depth analysis of the order of ORDERBY and GROUPY in mysql

The order of order by and group by in mysql is:
select
from
where
group by
order by
Note:group by is executed before order by , Order by will not sort the group by internally.If there is only one record after the group by, then the order by will be invalid.To find the largest or smallest field in the group by, use the max or min function.
Example:
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

Tags

Technical otaku

Sought technology together

Related Topic

0 Comments

Leave a Reply

+