SELECT, WHERE & ORDER BY · Question 20 · Hard
SELECT, WHERE & ORDER BY question 20
Table Students:
roll | name | city | marks
1 | Aarav | Pune | 78
2 | Diya | Mumbai | 91
3 | Kabir | Pune | 64
4 | Meena | Chennai | 91
5 | Rohan | Mumbai | NULL
6 | Sneha | Pune | 85
What does this query return?
SELECT DISTINCT marks
FROM Students
WHERE marks IS NOT NULL
ORDER BY marks DESC
LIMIT 1 OFFSET 1;
- 91
- 85
- 78
- 91; 85
Answer and explanation
Answer: B. 85
Explanation: DISTINCT is applied before ORDER BY and LIMIT, so the two 91s become one and the sorted list is 91, 85, 78, 64. Skipping one row and taking one gives 85; without DISTINCT the answer would have been the second 91.
Previous: Table Students: roll | name | city | marks 1 | Aarav | Pune | 78 2 | Diya |…
Practise select, where & order by
Try a fresh set of select, where & order by questions with an explanation after every answer, free and without signing up: SELECT, WHERE & ORDER BY practice. Or sit a full placement mock test.
More select, where & order by questions
- Table Students: roll | name | city | marks 1 | Aarav | Pune | 78 2 | Diya |…
- Table Payments: txn_id | payer | app | amount | status 1 | Farhan | GPay | 250…
- Table Students: roll | name | city | marks 1 | Aarav | Pune | 78 2 | Diya |…
More sql practice
SQL Joins · Aggregates & GROUP BY · Subqueries & CTEs · Window Functions · NULL Handling · SQL Functions & CASE · UNION, INTERSECT & EXCEPT · Tables, Keys & Constraints
LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge