1.Easy
An INNER JOIN returns:
- AAll rows from both tables
- BOnly rows with matching values in both tables
- CAll rows from the left table, with NULLs where there is no match
- DRows that do not match
2.Easy
In PostgreSQL and MySQL, which clause returns only the first 10 rows of a result?
- ATOP ROWS 10
- BFIRST 10 ONLY
- CLIMIT 10
- DMAX 10
3.Easy
What does WHERE country IN ('NL', 'BE', 'DE') do?
- AKeeps rows whose country is not in the list
- BSorts rows in the order of the list
- CKeeps rows whose country value contains all three codes at once
- DKeeps rows whose country equals any value in the list
4.Medium
Which query lists customers who have never placed an order?
- ASELECT c.name FROM customers c LEFT JOIN orders o ON o.customer_id = c.id WHERE o.id IS NOT NULL
- BSELECT c.name FROM customers c LEFT JOIN orders o ON o.customer_id = c.id WHERE o.id IS NULL
- CSELECT c.name FROM customers c LEFT JOIN orders o ON o.customer_id = c.id WHERE o.id = NULL
- DSELECT c.name FROM customers c INNER JOIN orders o ON o.customer_id = c.id WHERE o.id IS NULL
5.Medium
Which query returns the number of different cities in the customers table?
- ASELECT COUNT(city) FROM customers GROUP BY city
- BSELECT DISTINCT COUNT(city) FROM customers
- CSELECT SUM(DISTINCT city) FROM customers
- DSELECT COUNT(DISTINCT city) FROM customers
6.Medium
What does SELECT name, CASE WHEN grade >= 5.5 THEN 'pass' ELSE 'fail' END FROM results return?
- AAn error because CASE is not allowed in SELECT
- BThe number of students who passed and failed
- CEach name with the label 'pass' or 'fail' depending on the grade
- DOnly the students who passed
7.Hard
Why might a query with WHERE YEAR(order_date) = 2025 not use an index on order_date?
- AApplying a function to the column prevents a simple index range lookup
- BYEAR is not valid SQL
- CIndexes never work with dates
- DAn index on order_date is only used for ORDER BY clauses, never for WHERE
8.Hard
There is a composite index on (last_name, first_name). Which condition can use it most effectively?
- AWHERE first_name = 'Eva'
- BWHERE UPPER(first_name) = 'EVA'
- CWHERE first_name LIKE '%a'
- DWHERE last_name = 'Jansen'
Answer key
- 1. B · Only rows with matching values in both tables
- 2. C · LIMIT 10
- 3. D · Keeps rows whose country equals any value in the list
- 4. B · SELECT c.name FROM customers c LEFT JOIN orders o ON o.customer_id = c.id WHERE o.id IS NULL
- 5. D · SELECT COUNT(DISTINCT city) FROM customers
- 6. C · Each name with the label 'pass' or 'fail' depending on the grade
- 7. A · Applying a function to the column prevents a simple index range lookup
- 8. D · WHERE last_name = 'Jansen'
Full step-by-step solutions: practise this topic on examproblems.com.