The difference between order by and group by in mysql

  • 2020-05-30 21:12:49
  • OfStack

order by is the sorting of rows by default. After order by, you must list the sorted field names, which can be multiple field names.
group by means grouping. You must have an "aggregate function" to work with, and you need at least one grouping flag field.
What is an "aggregate function"?
Things like sum(), count(), avg(), and so on are "aggregate functions."
The purpose of using group by is to summarize the data.

Related articles: