1Which clause filters ROWS before aggregation?
- GROUP BY
- ORDER BY
- WHERE
- HAVING
- LIMIT
Show answerHide answer
C · WHERE WHERE filters individual rows; HAVING filters groups after aggregation.
13 questions from beginner to advanced, each with the correct answer and a one-line explanation of why. Study them here, or take them as a timed test.
C · WHERE WHERE filters individual rows; HAVING filters groups after aggregation.
B · HAVING HAVING applies conditions to aggregated results (e.g., HAVING SUM(x) > 100).
B · Only rows with a match in both tables INNER JOIN keeps only matching rows from both sides.
D · All left rows plus matches (NULLs where none) LEFT JOIN keeps every left-table row, filling NULLs where the right has no match.
D · Ignores NULLs in that column COUNT(col) skips NULLs; COUNT(*) counts all rows regardless of NULLs.
C · DISTINCT SELECT DISTINCT removes duplicate rows from the result set.
E · ORDER BY ORDER BY sorts the output (ASC by default, DESC optional).
C · Numbers rows within each partition without collapsing them Window functions add a per-row calculation over a partition while keeping all rows.
A · Leaves a gap in the next rank; DENSE_RANK does not RANK skips numbers after ties (1,1,3); DENSE_RANK does not (1,1,2).
A · A named temporary result set for the following query CTEs create a readable, reusable named subquery scoped to the statement.
E · One row per group GROUP BY collapses rows into one summary row per group.
D · The first non-NULL value COALESCE returns the first argument that isn't NULL.
E · References the outer query and runs per outer row A correlated subquery depends on the outer row, so it is evaluated for each outer row.