SELECT, WHERE & ORDER BY · Question 13 · Medium

A query has the clauses SELECT, FROM, WHERE, ORDER BY and LIMIT. In which logical order are they evaluated?

  1. SELECT, FROM, WHERE, ORDER BY, LIMIT
  2. FROM, SELECT, WHERE, ORDER BY, LIMIT
  3. FROM, WHERE, ORDER BY, SELECT, LIMIT
  4. FROM, WHERE, SELECT, ORDER BY, LIMIT
Answer and explanation

Answer: D. FROM, WHERE, SELECT, ORDER BY, LIMIT

Explanation: Rows are first read (FROM) and filtered (WHERE), then the SELECT list is computed, the result is sorted, and the row limit is applied last. This is why ORDER BY can use a SELECT alias but WHERE cannot.

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