HelpContactFor teachers and institutes
>_StemPy Lab
Mock TestsClasses

>_StemPy Lab

Learn. Solve. Code the solutions. Test yourself.

Live examsFree mock exams, timed and rankedEveryone starts together, and your score and rank come the moment it ends.See the exams →

Learn

  • Physics
  • Chemistry
  • Mathematics
  • Biology
  • Python Programming
  • Statistics & Data Science
  • Computer Science
  • Classes
  • Groups

Practice

  • Problems
  • Quizzes
  • Mock Tests
  • Prepare for an Exam
  • Question Sets
  • Exams
  • Certificates
  • Python Labs
  • AI Practice Generator
  • Student-Created Tests

Community

  • Discussions
  • Resources
  • Notes
  • Glossary
  • Blog

Account

  • Log in
© 2026 senLearn. All rights reserved.HelpFor SchoolsAboutContactPrivacy PolicyTerms of UseRefund Policy
  1. Notes
  2. /SELECT, WHERE and ORDER BY: Quick Revision
Computer Science

SELECT, WHERE and ORDER BY: Quick Revision

A brief note on SELECT, WHERE and ORDER BY: the parts of a query, the comparison operators, text and Boolean values, sorting, and how to work out the output, with practice, a program and questions to check yourself.

StemPy LabWritten by StemPy Lab
Log in to save

A brief note on SELECT, WHERE and ORDER BY. Read it before a test. Try each question at the end before you open its answer.

The parts of a query

  1. SELECT the fields to output, with commas between them, in the order you want.
  2. FROM the table.
  3. WHERE a condition (optional): only the records for which it is true.
  4. ORDER BY a field ASC or DESC (optional).
  5. A semicolon ends the script.

Conditions

  • Operators: =, <> (not equal to), >, <, >=, <=.
  • Text in quotes: WHERE Town = 'Hillview'.
  • Numbers without quotes: WHERE Age > 14.
  • Booleans: WHERE Paid = TRUE.
  • "At least" is >=, "more than" is >.

Sorting

  • ASC: smallest first, A to Z, earliest date first.
  • DESC: largest first, Z to A, latest date first.
  • Only the records that pass WHERE are sorted.

Working out the output

  1. Keep the records that meet the condition.
  2. Sort them, if there is ORDER BY.
  3. Write down only the selected fields, in the SELECT order.

Practice with new numbers

A program to try

The program builds a small table and runs a query with WHERE and ORDER BY.

Read it first. Then run it. Predict the output before you look.

1. Change >= 14 to > 14. Which member is no longer output?

Mistakes to avoid

  • No quotes round text. The database looks for a field of that name.
  • > for "at least". It leaves out the value itself.
  • Clauses in the wrong order. It is always SELECT, FROM, WHERE, ORDER BY.
  • Output in table order after ORDER BY. The output is sorted.

Check yourself

  1. Which clause chooses the fields to output?
  1. Write the condition for a Town field equal to Lakeside.
  1. Which comes first with ORDER BY Age ASC: 131313 or 161616?
  1. A script has WHERE Age > 15. Is a member aged 151515 output?
  1. Put in order: ORDER BY, SELECT, WHERE, FROM.

Sources

  • Cambridge International, IGCSE Computer Science 0478 syllabus (exams in 2026, 2027 and 2028), section 9 Databases, learning outcome 4.
← All Notes
← Database Tables and Keys: Quick RevisionCOUNT, SUM, AND and OR: Quick Revision →
More onComputer Science › Databases and SQL

Discussion (0)

Log in to join the discussion.

Loading…

On this page

  1. The parts of a query
  2. Conditions
  3. Sorting
  4. Working out the output
  5. Practice with new numbers
  6. A program to try
  7. Mistakes to avoid
  8. Check yourself
  9. Sources

Goes with the lesson

  1. ORDER BY: sorting the outputSQL Queries: SELECT, WHERE and ORDER BY

More notes on this topic

  1. COUNT, SUM, AND and OR: Quick Revision
  2. Database Tables and Keys: Quick Revision
  3. Logic Circuits and Truth Tables: Quick Revision
  4. NAND, NOR and XOR Gates: Quick Revision
  5. NOT, AND and OR Gates: Quick Revision
All notes on this topic →