SELECT, WHERE & ORDER BY · Question 9 · Medium

SELECT, WHERE & ORDER BY question 9

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

In what order are the names returned?

SELECT name
FROM Students
WHERE marks IS NOT NULL
ORDER BY city, marks DESC;
  1. Meena; Diya; Kabir; Aarav; Sneha
  2. Meena; Diya; Sneha; Aarav; Kabir
  3. Sneha; Aarav; Kabir; Diya; Meena
  4. Diya; Meena; Sneha; Aarav; Kabir
Answer and explanation

Answer: B. Meena; Diya; Sneha; Aarav; Kabir

Explanation: Rows are sorted by city ascending first (Chennai, Mumbai, Pune); DESC applies only to marks. Inside Pune the marks run 85, 78, 64, giving Sneha, Aarav, Kabir.

Previous: Table Products: pid | name | category | price | stock 1 | Kurta | Clothing |… · Next: 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

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