SQL • LESSON 04
ORDER BY
Learn how to sort SQL query results using the ORDER BY clause.
🟢 Beginner⏱ 2 Minutes⭐ 150 XP
🤔 THE QUESTION
How can we see how many employees belong to each department?
💡 WHAT IS IT?
GROUP BY combines rows with the same value so aggregate functions such as COUNT() can summarize each group.
🎯 WHAT IS IT USED FOR?
It is used for reports, summaries, counts, totals, averages, and analyzing data by categories.
💻 EXAMPLE
SELECT department,
COUNT(*)
FROM employees
GROUP BY department;Mission Brief
Practice sorting employee records by salary using ORDER BY.
Objectives
- ✓ SELECT
- ✓ FROM
- ✓ ORDER BY
- ✓ ASC / DESC