Learn in your language
Skip to content
IGCSE · Cambridge (CIE) · 0984

Sort query results in ascending order

Use ORDER BY ASCENDING to arrange the returned records by a field value.

Section 9 · Databases

Cambridge IGCSE Computer Science 0984 · Databases · 2026–2028 Version 4 · 0984 (9–1) · Topic 9
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

Does sorting remove records?

What you will learn

  • Place ORDER BY after the source and filter clauses
  • Sort by a selected field
  • Explain that sorting changes order, not the stored records

ORDER BY controls result order

Add ORDER BY followed by a field name and ASCENDING to list results from lower to higher values or alphabetically A to Z.

Place ORDER BY after FROM and any WHERE condition. The syllabus uses the full keyword ASCENDING.

Sorting is not filtering

ORDER BY rearranges the result rows; it does not add or remove records.

When two values are equal, the syllabus does not promise a particular relative order unless another sort field is supplied. Do not infer extra behavior from an example table.

Pause and explain

Which keyword requests alphabetical A-to-Z order?

Put the idea to work

Worked example

Return SessionID and Topic from WORKSHOP, alphabetically by Topic.

Show the worked solution
  1. Select the two fields to display.
  2. Name WORKSHOP after FROM.
  3. Sort by Topic in ascending order.

Answer SELECT SessionID, Topic FROM WORKSHOP ORDER BY Topic ASCENDING;

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.

1 · Guided

Write a query to display Name and YearGroup from STUDENTS in ascending YearGroup order.

Give me a hint

Use the sort field after ORDER BY.

Compare my reasoning
  1. Select Name and YearGroup.
  2. Use STUDENTS after FROM.
  3. Append ORDER BY YearGroup ASCENDING.

SELECT Name, YearGroup FROM STUDENTS ORDER BY YearGroup ASCENDING;

Look for these in your work

  • Fields
  • Table
  • Ascending clause
2 · Independent

A result originally shows scores 8, 3 and 6. What order is requested by ORDER BY Score ASCENDING?

Give me a hint

Arrange from smallest to largest.

Compare my reasoning
  1. Compare 3, 6 and 8.
  2. List the lowest first.
  3. Keep all three rows.

3, 6, 8; no row is removed.

Look for these in your work

  • Order correct
  • Rows retained
3 · Transfer

A user asks for the oldest event first and the table has a Date field. Which sort direction is appropriate if earlier dates are smaller? Explain.

Give me a hint

Ascending puts earlier values before later values.

Compare my reasoning
  1. Use Date as the sort field.
  2. Choose ascending order.
  3. Retain each matching event; only their order changes.

ORDER BY Date ASCENDING, because earlier dates should appear first.

Look for these in your work

  • Field chosen
  • Direction justified

Common mistakes

  • Putting ORDER BY before WHERE
  • Sorting by an incorrect field
  • Thinking a sort changes the data stored in the table
Recall without your notes

What can you explain now?

What does ORDER BY ASCENDING do?

Compare with the explanation

Orders results from lower to higher or A to Z

It determines the presentation order of result rows.

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

Where does ORDER BY appear in a query with WHERE?

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.

Keep learning Computer Science (9-1)

Course scope and assessment

165 original lessons map the listed objectives across all 10 main topics in the 2026–2028 Version 4 syllabus. Cambridge states that 0984 has the same subject content as 0478, with 9–1 grading. Three retained introductory lessons remain available but are not counted as syllabus-mapped teaching. The 2023–2025 syllabus remains unmapped. The separately published 2029–2031 syllabus changes to Python 3 only and removes pseudocode; this 2026–2028 route does not cover those changes. 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. Practical programming in an executable browser workspace, full timed-paper practice and human subject-teacher review remain outstanding. Practice is self-checked and does not award an official Cambridge grade.

StudyForA · Learn with understanding

Original teaching content and links to official sources. Check your exam year and qualification before using a resource.