Español Practice SQL

How to practice SQL for a data analyst interview

Interview SQL is not exotic. It is a small set of patterns asked under time pressure.

The patterns that keep coming back

  • Totals per group with GROUP BY and HAVING.
  • Joins, and especially LEFT JOIN to find what is missing.
  • The top row per group with ROW_NUMBER and PARTITION BY.
  • Running totals and change from the previous period with window functions.
  • Breaking a hard question into steps with WITH.

Practice the shape, not the answer

Memorising solutions does not help when the table is new. What helps is seeing the same shape on many different tables until you recognise it at once. That is why every practice task here builds a fresh table.

Say it before you type it

Before writing, say the plan out loud: “join deals to reps, group by rep, sort by total, keep one.” Interviewers care about that reasoning as much as the final query.

Check edge cases

  • What if two rows tie for first place?
  • What happens to customers with no orders?
  • Are there NULL values that change a count or an average?

Pick the Data analyst role in the practice: its tasks come from every team, like the requests analysts get at work.

Practice what you just read

Open the practice

Guides for this article

More articles