Sarthaks APP
0 votes
in Information Technology by (47.6k points)
closed by

What is the difference between the order by and group by clause when used along with the select statement. Explain with an example.

1 Answer

+1 vote
by (46.6k points)
selected by
Best answer

The order by clause is used to show the contents of a table/relation in a sorted manner with respect to the column mentioned after the order by clause. The contents of the column can be arranged in ascending or descending order.

The group by clause is used to group rows in a given column and then apply an aggregate function eg max(), min() etc on the entire group.

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.