Grokking SQL for Tech Interviews
Vote

0% completed

ORDER BY Clause

ORDER BY

In MySQL, the ORDER BY clause is used to sort the result set of a query based on one or more columns. It is typically used with the SELECT statement to arrange the rows in a specific order.

Syntax

SELECT column1, column2 FROM table_name WHERE condition ORDER BY column1 [ASC | DESC], column2 [ASC | DESC];

Here's a brief explanation of the components:

  • ASC: Ascending order (default). Rows are sorted from the smallest value to the largest value.
  • DESC: Descending order. Rows are sorted from the largest value to the smallest value.

.....

.....

.....

Like the course? Get enrolled and start learning!
Debopriyo Basu

Debopriyo Basu

· 2 years ago

The test case is for products table, but the question asked for employee table. Please rectify it.

Reading Progress

0%