Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (55.6k points)

Can anyone explain how to order by two columns in SQL?

1 Answer

0 votes
by (119k points)

Suppose, if you want to sort the table by Employee names in ascending order and Salaries in Ascending order. Here is the SQL query to order the table by employee name and salaries:

SELECT *

FROM Employee

ORDER BY Employee_Name, Salary DESC

The above query first sorts table by Employee names in alphabetical order. If employee names are the same then sorts those records with the same names by Salary column in descending order.

If you want to learn SQL and writing SQL queries, you can learn by registering for SQL Certification program by Intellipaat that provides Instructor-led training, certification, and also job assistance.

Related questions

0 votes
1 answer
asked Dec 6, 2020 in SQL by Appu (6.1k points)
0 votes
1 answer
asked May 4, 2020 in SQL by Sudhir_1997 (55.6k points)
0 votes
1 answer
asked May 4, 2020 in SQL by Sudhir_1997 (55.6k points)
0 votes
1 answer
asked Apr 28, 2020 in SQL by Sudhir_1997 (55.6k points)

Browse Categories

...