KnowledgeBoat Logo

Computer Science

What is the purpose of the following clauses in a select statement?

(i) ORDER BY

(ii) GROUP BY

SQL Queries

1 Like

Answer

(i) ORDER BY clause is used to sort the result set of a SELECT statement either in ascending (default) or descending order based on one or more columns. The ASC keyword is used for ascending order, and the DESC keyword is used for descending order.

(ii) GROUP BY clause is used to group rows that have the same values in specified columns into summary rows. It is commonly used with aggregate functions (e.g., SUM, COUNT, AVG) to perform calculations on grouped data.

Answered By

2 Likes


Related Questions