1.Easy
What does UNION do with the results of two SELECT queries?
- ACombines them into one result and removes duplicate rows
- BJoins them side by side on a key
- CKeeps only rows that appear in both
- DKeeps only rows that appear in the first query but not the second
2.Easy
Which statement adds a new column to an existing table?
- AALTER TABLE
- BINSERT COLUMN
- CUPDATE TABLE
- DCREATE COLUMN
3.Easy
Which SQL statement retrieves data from a table?
- AUPDATE
- BINSERT
- CCREATE
- DSELECT
4.Medium
Which query returns the number of orders per customer?
- ASELECT DISTINCT COUNT(*) FROM orders
- BSELECT customer_id, COUNT(*) FROM orders ORDER BY customer_id
- CSELECT customer_id, COUNT(*) FROM orders GROUP BY customer_id
- DSELECT customer_id FROM orders WHERE COUNT(*) > 0
5.Medium
A table has rows where col is NULL. Which rows does WHERE col = NULL return?
- AAll rows of the table
- BAn error in every database
- COnly the rows where col is NULL, as with IS NULL
- DNo rows, because the comparison is unknown
6.Medium
Which query returns the highest salary in each department?
- ASELECT MAX(dept), salary FROM emp GROUP BY salary
- BSELECT dept, salary FROM emp WHERE salary = MAX(salary)
- CSELECT dept, MAX(salary) FROM emp ORDER BY dept
- DSELECT dept, MAX(salary) FROM emp GROUP BY dept
7.Hard
Scores are 90, 90 and 80. Which values does RANK() OVER (ORDER BY score DESC) give?
- A2, 2, 3
- B1, 1, 3
- C1, 1, 2
- D1, 2, 3
8.Hard
What does SELECT day, SUM(amount) OVER (ORDER BY day) FROM sales compute?
- AOne row per day with that day's total only
- BThe average amount per day
- CThe total of all amounts on every row
- DA running total of amount ordered by day
Answer key
- 1. A · Combines them into one result and removes duplicate rows
- 2. A · ALTER TABLE
- 3. D · SELECT
- 4. C · SELECT customer_id, COUNT(*) FROM orders GROUP BY customer_id
- 5. D · No rows, because the comparison is unknown
- 6. D · SELECT dept, MAX(salary) FROM emp GROUP BY dept
- 7. B · 1, 1, 3
- 8. D · A running total of amount ordered by day
Full step-by-step solutions: practise this topic on examproblems.com.