1.Easy
Which keyword sorts the result of a query?
- ASORT
- BGROUP BY
- CARRANGE
- DORDER BY
2.Easy
Which SQL statement retrieves data from a table?
- ASELECT
- BINSERT
- CUPDATE
- DCREATE
3.Easy
In a LIKE pattern, what does the % wildcard stand for?
- AExactly one character in that position of the string
- BThe end of the string
- CAny sequence of zero or more characters
- DAny single digit
4.Medium
Which query returns the number of orders per customer?
- ASELECT customer_id FROM orders WHERE COUNT(*) > 0
- BSELECT DISTINCT COUNT(*) FROM orders
- CSELECT customer_id, COUNT(*) FROM orders ORDER BY customer_id
- DSELECT customer_id, COUNT(*) FROM orders GROUP BY customer_id
5.Medium
What does a common table expression (WITH name AS (...)) provide?
- AA new database user
- BA named temporary result that can be used within one statement
- CAn index on a column
- DA permanent table that stays stored on disk until it is dropped
6.Medium
A foreign key is declared with ON DELETE CASCADE. What happens when a parent row is deleted?
- AThe foreign key in the child rows is set to NULL automatically
- BThe child rows that reference it are deleted automatically
- CThe delete is always rejected
- DThe parent row is copied to an archive table
7.Hard
Why is NATURAL JOIN considered risky in production queries?
- AIt always returns a Cartesian product
- BIt joins on every column with the same name, so a new column can silently change the result
- CIt ignores primary and foreign keys and keeps only NULL rows
- DIt is not supported by any database
8.Hard
Scores are 90, 90 and 80. Which values does RANK() OVER (ORDER BY score DESC) give?
- A1, 2, 3
- B1, 1, 2
- C1, 1, 3
- D2, 2, 3
Answer key
- 1. D · ORDER BY
- 2. A · SELECT
- 3. C · Any sequence of zero or more characters
- 4. D · SELECT customer_id, COUNT(*) FROM orders GROUP BY customer_id
- 5. B · A named temporary result that can be used within one statement
- 6. B · The child rows that reference it are deleted automatically
- 7. B · It joins on every column with the same name, so a new column can silently change the result
- 8. C · 1, 1, 3
Full step-by-step solutions: practise this topic on examproblems.com.