LearnStanmorephysics

Grade 12 · Matric Mastery

SELECT, WHERE & ORDER BY

Grade 12 · Databases & SQL · SQL lab · about 18 minutes

Open this task in the Delphi workspace →

SQL (Structured Query Language) asks the database questions. The skeleton:

SELECT fields          which columns you want (* = all)
FROM   tblLearners     which table
WHERE  condition       which rows qualify (optional)
ORDER BY field DESC    how to sort (optional)

Conditions look like Delphi's but with single = and no brackets needed: Grade = 12, ITMark >= 75, Province = 'Gauteng' (text in single quotes!). Combine with AND/OR. Patterns use LIKE with % as the wildcard: Surname LIKE 'M%' — surnames starting with M.

ORDER BY Surname sorts A→Z; add DESC for highest-first. This is the tblLearners table you are querying — the DBGrid below the editor shows live results every time you press Run.

Exam tip. Text values take quotes, numbers do not: Province = 'Gauteng' but Grade = 12. Mixing that up is the most common lost mark in the SQL question.

About this material

This platform provides original CAPS-aligned practice material and study tools. Content is machine-verified and has not been reviewed by subject specialists. It is not affiliated with or endorsed by the Department of Basic Education. Learners should also use official past papers and consult their teachers where uncertain.