Informatics Practices

Can you arrange the result set of an SQL query on multiple columns ?

SQL Queries

2 Likes

Answer

Yes, we can arrange the result set of an SQL query on multiple columns. We should specify the multiple column names in the ORDER BY clause along with the desired sort order.

For example, the following statement will sort the records in the data table first by the section column in ascending order and then by the marks column in descending order.

SELECT * FROM data
ORDER BY section ASC, marks DESC;

Answered By

2 Likes


Related Questions