1.Easy
What does GROUP BY do in a query?
- AJoins two tables on their common columns
- BRemoves rows with NULL values
- CPuts rows with the same values into groups so aggregates are computed per group
- DSorts the rows of the result alphabetically
2.Easy
An INNER JOIN returns:
- ARows that do not match
- BAll rows from both tables
- COnly rows with matching values in both tables
- DAll rows from the left table, with NULLs where there is no match
3.Easy
What does a CHECK constraint do?
- ARejects rows whose values do not satisfy a condition
- BChecks whether a table exists before a query is run on it
- CCounts the rows in a table
- DVerifies the user's password
4.Medium
A LEFT JOIN returns:
- AAll rows from the left table and matching rows from the right, with NULLs where there is no match
- BRows that match in neither table
- COnly matching rows from both tables
- DAll rows from the right table only
5.Medium
What does GRANT SELECT ON employees TO alice do?
- AMakes alice the owner of the database
- BAllows the user alice to read the employees table
- CCopies the employees table to alice
- DAllows alice to update and delete rows in the employees table
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 GROUP BY dept
- DSELECT dept, MAX(salary) FROM emp ORDER BY dept
7.Hard
What does the following return: SELECT name FROM students WHERE grade > (SELECT AVG(grade) FROM students)?
- AThe average grade of all students
- BStudents with a grade above the average grade
- CAn error because subqueries are not allowed in WHERE
- DStudents with the highest grade only
8.Hard
Why might a query with WHERE YEAR(order_date) = 2025 not use an index on order_date?
- AAn index on order_date is only used for ORDER BY clauses, never for WHERE
- BYEAR is not valid SQL
- CIndexes never work with dates
- DApplying a function to the column prevents a simple index range lookup
Answer key
- 1. C · Puts rows with the same values into groups so aggregates are computed per group
- 2. C · Only rows with matching values in both tables
- 3. A · Rejects rows whose values do not satisfy a condition
- 4. A · All rows from the left table and matching rows from the right, with NULLs where there is no match
- 5. B · Allows the user alice to read the employees table
- 6. C · SELECT dept, MAX(salary) FROM emp GROUP BY dept
- 7. B · Students with a grade above the average grade
- 8. D · Applying a function to the column prevents a simple index range lookup
Full step-by-step solutions: practise this topic on examproblems.com.