Sort query results in descending order
Use ORDER BY DESCENDING to place larger or later values first.
Section 9 · Databases
Exam scope and assessment notes
This sequence follows Cambridge IGCSE Computer Science 0984, 2026–2028 syllabus Version 4, Topic 9. It covers single-table databases only and the specified SELECT, FROM, WHERE, ORDER BY, SUM, COUNT, AND and OR content. The official specimen also demonstrates NOT in a filter. Multi-table joins, GROUP BY, database implementation and the separate 2029–2031 syllabus are not mapped here. Practice is original, self-checked and does not award an official Cambridge grade. Full timed papers and human subject-teacher review remain outstanding. Cambridge states that 0984 has the same 2026–2028 subject content as 0478, with 9–1 grading. In June and November, Cambridge lists 0984 in Administrative zone 3 and for centres in Oman and the UAE. Confirm availability for your centre and exam series with Cambridge International. The separately published 2029–2031 syllabus changes to Python 3 only and removes pseudocode; this 2026–2028 route does not cover those changes.
Before you begin
- Be able to read a small table and compare values. Each lesson introduces the database and SQL terms it uses.
Work on paper. Try each question before revealing help, and explain why your method works.
Quick readiness check
What does DESCENDING mean for numeric values?
What you will learn
- Read descending order as high to low
- Write the ORDER BY clause
- Use sorting to answer ranking requests
Descending reverses ascending order
ORDER BY FieldName DESCENDING lists larger values before smaller ones, or later alphabetical values before earlier ones.
Use DESCENDING when the request asks for the highest, newest or Z-to-A result first, subject to the field's meaning.
Keep the query clauses in order
A query can select fields, name a source table, filter records with WHERE and finally sort with ORDER BY.
The sort direction does not change which rows match a WHERE condition. Apply the requested filter first conceptually, then order those results.
Pause and explain
A leaderboard asks for the highest score first. Which clause is appropriate?
Worked example
Return Title and Seats from WORKSHOP with the largest number of seats first.
Show the worked solution
- Select Title and Seats.
- Use WORKSHOP as the source table.
- Sort Seats in descending order.
Answer SELECT Title, Seats FROM WORKSHOP ORDER BY Seats DESCENDING;
Try a topic test
Choose Easy, Normal or Difficult. Save your answers and open worked review after finishing.
Test this topic →From guided practice to a new situation
Write your answer and reasoning first. Use a hint only if you are stuck. The model solution is for self-checking; your written work is not automatically marked.
Write a query to return Name and Points from TEAMS, highest points first.
Give me a hint
Use descending order on Points.
Compare my reasoning
- Select Name and Points.
- Use TEAMS after FROM.
- Sort by Points DESCENDING.
SELECT Name, Points FROM TEAMS ORDER BY Points DESCENDING;
Look for these in your work
- Fields
- Table
- Direction
Scores are 61, 90 and 75. Give their output order for DESCENDING.
Give me a hint
Place the greatest first.
Compare my reasoning
- 90 is greatest.
- 75 is next.
- 61 is least.
90, 75, 61.
Look for these in your work
- Largest identified
- Sequence correct
A query filters workshops with Seats >= 10 and sorts Seats descending. Does the sort cause a workshop with 8 seats to appear? Explain.
Give me a hint
Filtering decides membership before display order.
Compare my reasoning
- Seats >= 10 excludes the 8-seat row.
- ORDER BY only rearranges rows that remain.
- The row does not appear.
No; WHERE excludes it, and descending order only sorts matching rows.
Look for these in your work
- Filter effect
- Sort effect
Common mistakes
- Using ASCENDING when largest-first is required
- Sorting by the displayed title instead of the requested score
- Believing sort direction affects WHERE
What can you explain now?
Which direction puts the largest numeric value first?
Compare with the explanation
DESCENDING
Descending order goes from larger to smaller values.
After trying it yourself, choose your next review. This is your self-assessment.
Your review choice appears on Today. Sign in to sync it across devices.
Make it stick
What kind of request signals that descending order may be needed?
If you needed the solution, close it and solve the problem again from a blank page. A correct answer is stronger when you can explain the reason for each step.