GCSE Computer Science, Unit 2, Lesson 6 of 6
Brainlag Plus

SQL, files and random numbers

GCSE Computer Science, Programming in exam style, 20 minutes

Have Plus? Sign in

Read SELECT queries with WHERE and ORDER BY, store data in files, and use random numbers.

SQL queries

A database table stores records (rows) made of fields (columns).

SQL asks questions of it.

SELECT Name, Score
FROM Pupils
WHERE Club = 'Chess' AND Score > 50
ORDER BY Score DESC
  • SELECT names the fields to show (* means all of them).
  • FROM names the table.
  • WHERE keeps only the records that meet the condition. AND needs both conditions; OR needs either.
  • ORDER BY sorts: ASC (the default) is smallest or A first, DESC is largest or Z first.

Practise SQL for real: SELECT, WHERE and ORDER BY on Brainlag Code.

The rest of this lesson and its 7 practice questions are in Plus.

Screen 1 of 3, free to read.

  • 7 exam-style questions, marked as you go, each with a worked solution
  • Anything you get wrong is saved to your flashcards