Wednesday, March 6, 2013

group by and order by difference in mysql

OREDER BY sort your result set into asc or desc order, asc in the default.
whereas The GROUP BY keyword is used when we are selecting multiple columns from a table (or tables) and at least one arithmetic operator appears in the SELECT statement. When that happens, we need to GROUP BY all the other selected columns, i.e., all columns except the one(s) operated on by the arithmetic operator
down vote accepted
ORDER BY alters the order in which items are returned.
GROUP BY will aggregate records by the specified columns which allows you to perform aggregation functions on non-grouped columns (such as SUM, COUNT, AVG, etc).
.

No comments:

Post a Comment