SQL: Selecting, Filtering and Ordering Rows · seed 1 · A4, ink-friendly. The answer key prints on its own page for grown-ups.

Ask the database a precise question

Computing · Computer Systems · ages 17-18
Name ______________________   Date ____________
  1. What does the WHERE clause do?

    • Sorts the surviving rows
    • Keeps only rows passing its test
    • Creates a new table
  2. In SELECT title, author FROM Books, what does SELECT do?

    • Names the columns to return
    • Deletes the whole table
    • Sorts the authors
  3. OR keeps only the rows that pass both sides of the test.

    Circle one:   True   False

  4. WHERE NOT returned. Which rows survive?

    • Every row in the table
    • Rows where the book is still out
    • Rows where the book is back on the shelf
  5. WHERE pages > 300 AND borrowed = yes. Which books survive?

    • Borrowed books, long or not
    • Long books, borrowed or not
    • Only books that are both long and borrowed
  6. ORDER BY title followed by LIMIT 10 returns the first ten titles alphabetically.

    Circle one:   True   False

  7. A query fails on a column that does not exist. What should you check first?

    • The schema, to see the real tables and columns
    • The keyboard, for stuck keys
    • The clock, for the wrong time
  8. Which query lists the titles of books borrowed after 2025-06-01, sorted by title?

    • SELECT * FROM Books WHERE title > '2025-06-01' ORDER BY borrowed_on
    • SELECT title FROM Books ORDER BY title WHERE borrowed_on > '2025-06-01'
    • SELECT title FROM Books WHERE borrowed_on > '2025-06-01' ORDER BY title
LightMySky · lightmysky.comW1-mt_lDVVG2AKzs-s1

Answer key

For grown-ups. Fold this page away before handing over the rest.

Ask the database a precise question W1-mt_lDVVG2AKzs-s1

  1. Keeps only rows passing its test · WHERE tests every row and drops the ones that fail.
  2. Names the columns to return · SELECT lists the columns you want to see.
  3. False · That is AND. OR keeps rows passing either side.
  4. Rows where the book is still out · NOT flips the test, keeping the opposite rows.
  5. Only books that are both long and borrowed · AND needs both sides, so only long borrowed books pass.
  6. True · Sorting arranges the survivors, and LIMIT trims to the first ten.
  7. The schema, to see the real tables and columns · Queries name tables and columns from the schema, so the schema settles it.
  8. SELECT title FROM Books WHERE borrowed_on > '2025-06-01' ORDER BY title · Filter to the recent loans, then sort those survivors by title.
Worksheet · LightMySky