When sorting by multiple columns, which character is used to separate column names?
Explanation
Example:
SELECT column1, column2
FROM ...
ORDER BY columnN, columnM
In this case the result set will be sorted by columnN first and then, those records that have the same columnN values will be sorted by columnN value.
Theory
  • SQL - ORDER BY Clause

    The SQL ORDER BY clause is used to sort the data in ascending or descending order, based on one or more columns. Some database sorts query results in ascending order by default.

    Syntax:

    The basic syntax of ORDER BY clause is as follows:
    SELECT column-list 
    FROM table_name 
    [WHERE condition] 
    [ORDER BY column1, column2, .. columnN] [ASC | DESC];
    
    You can use more than one column in the ORDER BY clause. Make sure whatever column you are using to sort, that column should be in column-list.
    Read more: SQL - ORDER BY Clause

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Keep exploring
SQL quizzes
Cosmo
Sign Up Now
or Subscribe for future quizzes