1.Easy
Which SQL statement retrieves data from a table?
- ASELECT
- BCREATE
- CINSERT
- DUPDATE
2.Easy
Statements such as CREATE, ALTER and DROP belong to which part of SQL?
- ATransaction Control Language (TCL)
- BData Control Language (DCL)
- CData Definition Language (DDL)
- DData Manipulation Language (DML)
3.Easy
Which statement deletes a whole table, including its structure?
- ADROP TABLE
- BDELETE FROM
- CREMOVE TABLE
- DTRUNCATE ROWS
4.Medium
When is WHERE EXISTS (subquery) true for a row?
- AWhen the subquery returns a number greater than zero
- BWhen the subquery returns no NULL values
- CWhen the subquery returns exactly one row
- DWhen the subquery returns at least one row
5.Medium
Which query returns the highest salary in each department?
- ASELECT MAX(dept), salary FROM emp GROUP BY salary
- BSELECT dept, MAX(salary) FROM emp GROUP BY dept
- CSELECT dept, MAX(salary) FROM emp ORDER BY dept
- DSELECT dept, salary FROM emp WHERE salary = MAX(salary)
6.Medium
Which query returns the number of different cities in the customers table?
- ASELECT COUNT(city) FROM customers GROUP BY city
- BSELECT SUM(DISTINCT city) FROM customers
- CSELECT DISTINCT COUNT(city) FROM customers
- DSELECT COUNT(DISTINCT city) FROM customers
7.Hard
Scores are 90, 90 and 80. Which values does RANK() OVER (ORDER BY score DESC) give?
- A2, 2, 3
- B1, 2, 3
- C1, 1, 2
- D1, 1, 3
8.Hard
There is a composite index on (last_name, first_name). Which condition can use it most effectively?
- AWHERE first_name LIKE '%a'
- BWHERE last_name = 'Jansen'
- CWHERE first_name = 'Eva'
- DWHERE UPPER(first_name) = 'EVA'
Answer key
- 1. A · SELECT
- 2. C · Data Definition Language (DDL)
- 3. A · DROP TABLE
- 4. D · When the subquery returns at least one row
- 5. B · SELECT dept, MAX(salary) FROM emp GROUP BY dept
- 6. D · SELECT COUNT(DISTINCT city) FROM customers
- 7. D · 1, 1, 3
- 8. B · WHERE last_name = 'Jansen'
Full step-by-step solutions: practise this topic on examproblems.com.