SQL interview questions for data analystsTechnical interview questions
← Interview & exam prep
Technical interview questions

SQL interview questions for data analysts

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.

13 questionsBeginner 7 · Intermediate 6Answers + explanations
Take it as a timed test
Free PDF
All 389 questions & answers, in one file

DAX, Excel, Power BI, Fabric, certification practice and analyst interviews — every answer with the reason behind it. Print it, study it offline.

Instant download, plus the free Tuesday briefing. Unsubscribe in one click.

Beginner 7 questions

1Which clause filters ROWS before aggregation?

  1. GROUP BY
  2. ORDER BY
  3. WHERE
  4. HAVING
  5. LIMIT
Show answerHide answer

C · WHERE WHERE filters individual rows; HAVING filters groups after aggregation.

2Which clause filters GROUPS after aggregation?

  1. ORDER BY
  2. HAVING
  3. GROUP BY
  4. DISTINCT
  5. WHERE
Show answerHide answer

B · HAVING HAVING applies conditions to aggregated results (e.g., HAVING SUM(x) > 100).

3An INNER JOIN returns…

  1. All rows from both tables
  2. Only rows with a match in both tables
  3. Rows with no match
  4. All left rows
  5. All right rows
Show answerHide answer

B · Only rows with a match in both tables INNER JOIN keeps only matching rows from both sides.

4A LEFT JOIN returns…

  1. All right rows
  2. Only matches
  3. No rows
  4. All left rows plus matches (NULLs where none)
  5. A cross product
Show answerHide answer

D · All left rows plus matches (NULLs where none) LEFT JOIN keeps every left-table row, filling NULLs where the right has no match.

5COUNT(column) differs from COUNT(*) because it…

  1. Is invalid
  2. Counts duplicates only
  3. Counts faster
  4. Ignores NULLs in that column
  5. Counts columns
Show answerHide answer

D · Ignores NULLs in that column COUNT(col) skips NULLs; COUNT(*) counts all rows regardless of NULLs.

6To return only unique rows/values use…

  1. DEDUPE
  2. GROUP
  3. DISTINCT
  4. ONLY
  5. UNIQUE
Show answerHide answer

C · DISTINCT SELECT DISTINCT removes duplicate rows from the result set.

7Which clause sorts the result?

  1. RANK
  2. GROUP BY
  3. WHERE
  4. SORT
  5. ORDER BY
Show answerHide answer

E · ORDER BY ORDER BY sorts the output (ASC by default, DESC optional).

Intermediate 6 questions

8ROW_NUMBER() OVER(PARTITION BY … ORDER BY …) …

  1. Deletes duplicates
  2. Filters rows
  3. Numbers rows within each partition without collapsing them
  4. Sums a column
  5. Collapses rows into groups
Show answerHide answer

C · Numbers rows within each partition without collapsing them Window functions add a per-row calculation over a partition while keeping all rows.

9RANK() vs DENSE_RANK(): after a tie, RANK…

  1. Leaves a gap in the next rank; DENSE_RANK does not
  2. Restarts at 1
  3. Is identical
  4. Has no gaps
  5. Returns NULL
Show answerHide answer

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).

10A CTE (WITH name AS (…)) is…

  1. A named temporary result set for the following query
  2. A trigger
  3. An index
  4. A stored procedure
  5. A permanent table
Show answerHide answer

A · A named temporary result set for the following query CTEs create a readable, reusable named subquery scoped to the statement.

11A query with GROUP BY and an aggregate returns…

  1. All rows
  2. A cross join
  3. One row per input row
  4. No rows
  5. One row per group
Show answerHide answer

E · One row per group GROUP BY collapses rows into one summary row per group.

12COALESCE(a, b, c) returns…

  1. The sum
  2. The average
  3. NULL if any is NULL
  4. The first non-NULL value
  5. The last value
Show answerHide answer

D · The first non-NULL value COALESCE returns the first argument that isn't NULL.

13A correlated subquery…

  1. Returns all columns
  2. Runs once independently
  3. Is always faster
  4. Cannot use WHERE
  5. References the outer query and runs per outer row
Show answerHide answer

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.

Coming soon $19 one-time · early-access price
Prep Pro: full mock exams
  • Full-length, timed mock exams in the real PL-300, DP-600 and MO-201 format
  • Score breakdown by skill, with a study plan for your weak spots
  • New questions every month, written against the current exam outline

No payment now. We'll email you once, when it opens.

More technical interview questions