Question 1
SQL Logical Execution Order
FROM → JOIN → WHERE → GROUP BY → HAVING → SELECT → ORDER BY → LIMIT
5 questions. Use Show Answer, then slide right (or use Next) to continue.
FROM → JOIN → WHERE → GROUP BY → HAVING → SELECT → ORDER BY → LIMIT
WHERE filters rows before aggregation.HAVING filters after aggregation.SELECT *
FROM (
SELECT *,
ROW_NUMBER() OVER (
PARTITION BY key_col
ORDER BY ts DESC
) AS rn
FROM table
) t
WHERE rn = 1;
SELECT key_col,
COALESCE(SUM(amount), 0) AS total_amount
FROM table
GROUP BY key_col;
SELECT columns
FROM table
JOIN other_table ON condition
WHERE condition
GROUP BY columns
HAVING aggregate_condition
ORDER BY column DESC
LIMIT 10;