How to sort the rows in SQL?

How to sort the rows in SQL?

View Answers

November 19, 2010 at 4:17 PM

Hi,

Here is the answer,

The ORDER BY clause allows you to sort the records in your result set. The ORDER BY clause can only be used in SELECT statements.

The syntax for the ORDER BY clause is:

SELECT column_list
FROM tablename
WHERE expression
ORDER BY column ASC / DESC;

The ORDER BY clause sorts the result set based on the columns specified. If the ASC or DESC value is omitted, it is sorted by ASC.

ASC indicates ascending order. (default)

DESC indicates descending order.

Thanks,









Related Tutorials/Questions & Answers:
Advertisements