1.Easy
What does a CROSS JOIN return?
- AEvery combination of rows from the two tables
- BOnly rows that do not match
- COnly the rows that match on a shared key column
- DThe rows of the first table only
2.Easy
Which aggregate function returns the average of a numeric column?
- AAVG
- BSUM
- CMEAN
- DMEDIAN
3.Easy
What does a CHECK constraint do?
- ACounts the rows in a table
- BVerifies the user's password
- CChecks whether a table exists before a query is run on it
- DRejects rows whose values do not satisfy a condition
4.Medium
What does EXCEPT (called MINUS in Oracle) return?
- ARows that appear in both queries
- BRows of the first query that do not appear in the second
- CAll rows from both queries without duplicates
- DRows of the second query that do not appear in the first one
5.Medium
Which query returns the highest salary in each department?
- ASELECT dept, MAX(salary) FROM emp GROUP BY dept
- BSELECT dept, salary FROM emp WHERE salary = MAX(salary)
- CSELECT MAX(dept), salary FROM emp GROUP BY salary
- DSELECT dept, MAX(salary) FROM emp ORDER BY dept
6.Medium
A LEFT JOIN returns:
- AAll rows from the left table and matching rows from the right, with NULLs where there is no match
- BAll rows from the right table only
- COnly matching rows from both tables
- DRows that match in neither table
7.Hard
Table b contains the values 1, 2 and NULL in column y. What does SELECT * FROM a WHERE x NOT IN (SELECT y FROM b) return?
- ANo rows at all
- BEvery row of a
- CRows of a where x is not 1 or 2
- DOnly rows of a where x is NULL
8.Hard
A table has a million rows and a Boolean column is_active that is TRUE for 95% of them. Why might the optimiser ignore an index on is_active for WHERE is_active = TRUE?
- ATRUE is treated as NULL by the index
- BThe optimiser never uses indexes in WHERE clauses
- CMost rows match, so a full table scan is cheaper than many index lookups
- DIndexes cannot be created on Boolean columns
Answer key
- 1. A · Every combination of rows from the two tables
- 2. A · AVG
- 3. D · Rejects rows whose values do not satisfy a condition
- 4. B · Rows of the first query that do not appear in the second
- 5. A · SELECT dept, MAX(salary) FROM emp GROUP BY dept
- 6. A · All rows from the left table and matching rows from the right, with NULLs where there is no match
- 7. A · No rows at all
- 8. C · Most rows match, so a full table scan is cheaper than many index lookups
Full step-by-step solutions: practise this topic on examproblems.com.