Difference Between ORDER BY Clause and GROUP BY Clause in SQL?
Deepak Verma
http://www.essentialsql.com/what-is-the-difference-between-group-by-and-order-by/
Order By is used for sorting of data either in ascending order or in descending order where Group By is used for combining the value of unique combination .Group by used when any aggregate function is used in query..
On the surface both clauses appear to do the same thing, that is sort data. But this is where their similarities end. Both serve entirely different purposes. -> ORDER BY clause's purpose is to sort the query result by specific columns. -> GROUP BY clause's purpose is summarize unique combinations of columns values.
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)