1.Easy
What does GROUP BY do in a query?
- ASorts the rows of the result alphabetically
- BJoins two tables on their common columns
- CPuts rows with the same values into groups so aggregates are computed per group
- DRemoves rows with NULL values
2.Easy
How do you sort a result from the highest to the lowest salary?
- AORDER BY salary DESC
- BORDER BY salary ASC
- CGROUP BY salary DESC
- DSORT salary DOWN
3.Easy
An INNER JOIN returns:
- AOnly rows with matching values in both tables
- BAll rows from both tables
- CAll rows from the left table, with NULLs where there is no match
- DRows that do not match
4.Medium
A column holds the values 10, 20 and NULL. What does AVG(col) return?
- A30
- B15
- C10
- DNULL
5.Medium
Which query returns the highest salary in each department?
- ASELECT dept, MAX(salary) FROM emp ORDER BY dept
- BSELECT MAX(dept), salary FROM emp GROUP BY salary
- CSELECT dept, salary FROM emp WHERE salary = MAX(salary)
- DSELECT dept, MAX(salary) FROM emp GROUP BY dept
6.Medium
What does SELECT name, CASE WHEN grade >= 5.5 THEN 'pass' ELSE 'fail' END FROM results return?
- AEach name with the label 'pass' or 'fail' depending on the grade
- BThe number of students who passed and failed
- COnly the students who passed
- DAn error because CASE is not allowed in SELECT
7.Hard
Two-phase locking (2PL) ensures:
- AThat deadlocks can never happen
- BThat transactions never wait
- CConflict-serializable schedules
- DThat no locks are needed
8.Hard
When is a schedule of concurrent transactions called serializable?
- AWhen no transaction ever reads data
- BWhen every transaction is given a serial number
- CWhen the transactions run on one CPU only
- DWhen its effect is equivalent to some serial execution of the same transactions
Answer key
- 1. C · Puts rows with the same values into groups so aggregates are computed per group
- 2. A · ORDER BY salary DESC
- 3. A · Only rows with matching values in both tables
- 4. B · 15
- 5. D · SELECT dept, MAX(salary) FROM emp GROUP BY dept
- 6. A · Each name with the label 'pass' or 'fail' depending on the grade
- 7. C · Conflict-serializable schedules
- 8. D · When its effect is equivalent to some serial execution of the same transactions
Full step-by-step solutions: practise this topic on examproblems.com.