Skip to main content
SQL โ€ข LESSON 55

Multiple Column Sorting

How can we sort by department and then salary?

Beginnerโฑ 3 Minutesโญ 680 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