Skip to main content
SQL • LESSON 55

Multiple Column Sorting

How can we sort by department and then salary?

Beginner3 Minutes680 XP
🤔 THE QUESTION

How can we sort by department and then salary?

💡 WHAT IS IT?

Comma-separated columns in ORDER BY apply secondary and tertiary sort orders when primary values tie.

🎯 WHAT IS IT USED FOR?

Department rosters sorted by seniority or compensation, categorized product listings.

💻 EXAMPLE
SELECT name, department, salary
FROM employees
ORDER BY department, salary DESC;

🎯 Mission Objectives

Practice typing production-grade SQL code for Multiple Column Sorting.

  • Multi-column sort
  • Tie-breaking
  • Hierarchical ordering
  • Clean SQL formatting