What is the difference between group by and order by?

Group by controls the presentation of the rows, order by controls the presentation of the columns for the results of the SELECT statement.

Showing Answers 1 - 10 of 10 Answers

sul

  • Oct 30th, 2006
 

u can use aggregate functions (sum, avg etc) with group by

  Was this answer useful?  Yes

anilp

  • Nov 9th, 2006
 

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.

eg1: SELECT NAME FROM TABLE1 GROUP BY ROLLNO

Can use Agregate functions with GROUP BY

EG2:SELECT NAME FROM TABLE1 ORDER BY ROLLNO ASC

Blue Gazoo

  • Dec 9th, 2006
 

Group By forms Groups (of course), but this means it also SORTS; but it will also retrieve a DISTINCT RECORD SET

ORDER BY Sorts by the columns included in the Statement, and does not retrieve DISTINCT Records.

Neither determines the order of the columns (the order of the SELECT Statement does).

Siddhesh

  • Oct 16th, 2016
 

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.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions