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?
- SELECT, FROM, WHERE, ORDER BY, LIMIT
- FROM, SELECT, WHERE, ORDER BY, LIMIT
- FROM, WHERE, ORDER BY, SELECT, LIMIT
- 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
- 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 Products: pid | name | category | price | stock 1 | Kurta | Clothing |…
- 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 Products: pid | name | category | price | stock 1 | Kurta | Clothing |…
- 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 |…
- 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