Stop 15 · Interview PreparationSQL & Technical · 1/3

Live SQL Coding Questions

Part of the Data Analyst Roadmap

In short

In a live SQL round, the interviewer cares as much about how you think as whether the query runs. Talking through a clear process often matters as much as the final answer.

Being asked to write a working SQL query live, often on a shared screen or online editor — testing not just correctness but how you think through the problem out loud.

The jaadu cooks at a stove while two judges with clipboards watch from behind a counter.

Think of it like this

Cooking in front of judges

On a cooking show, judges watch every step. The contestant who explains "I'm browning the onions first for sweetness" scores better than one who cooks in silence, even if both dishes taste fine. Narrate your SQL the same way.

Watch it happen

How to tackle a live SQL question

Clarify
Sample rows
Build up
Edge cases
Explain

1/5"Second highest salary per department." Ask: what if two people tie? What if a department has one person?

The big ideas

What you need to know

Clarify before typing

Ask about ties, NULLs, duplicates and expected output. Interviewers often leave these vague on purpose.

Build in CTEs

Break the problem into named steps. It's easier to explain, debug and read under pressure.

Know window functions

ROW_NUMBER, RANK, DENSE_RANK, LAG and running SUMs show up in most analyst SQL rounds.

Think out loud

If you get stuck, say what you're trying. Interviewers can nudge you only if they know where you are.

See it in code

Walk through the code

sql
1WITH ranked AS (2  SELECT3    department,4    employee_name,5    salary,6    DENSE_RANK() OVER (7      PARTITION BY department ORDER BY salary DESC8    ) AS rnk9  FROM employees10)11SELECT department, employee_name, salary12FROM ranked13WHERE rnk = 2;

1/3A CTE holds the ranked rows, so the final query stays simple.

A classic question. DENSE_RANK handles ties so the second distinct salary is found even if two people share the top one.

Save yourself the pain

Common mistakes

Oops

Starting to type immediately and discovering halfway that you misread the question.

Do this instead

Restate the question and ask about edge cases first. Thirty seconds saves five minutes.

Oops

Going silent for minutes when stuck.

Do this instead

Say what you're considering. "I think a self-join works, but a window function may be cleaner."

Your mission

Practise out loud

~40 min

Quick check

Salaries in one department are 90, 90, 80. Using DENSE_RANK, which salary gets rank 2?

Go deeper

  1. 1Practice on a SQL interview question platform under light time pressure.
  2. 2Talk through your approach out loud before writing any code, even in practice.
  3. 3Review joins, window functions and CTEs specifically — the most commonly tested topics.

More sql & technical at this stop

Stuck on this topic? Ask an Insider

Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.

Download
InsideEdge