r/learnSQL • • 4h ago

What kind of SQL questions do companies usually ask in technical interviews?

I'm preparing for SQL interviews and curious about what companies actually focus on during technical rounds.

Do they mostly ask basic queries, JOINs, subqueries, window functions, or real-world problem-solving questions? Would love to hear what you experienced in your interviews.

5 Upvotes

5 comments sorted by

3

u/Existing-Mirror7787 4h ago

Based on two interviews I've had

One was a question asking theoretically what would you do to clean this input data & how (easy single line queries)

The other was a real piece of code in their company, asked me what it did & left me with it for 15 mins.

Safe to say I had no idea so when they came back 15 mins later I was just honest with them lol and wished them a good day

2

u/Entre2017 4h ago

One asked me to describe a time I used SQL query to solve a real business issue or something like that.

2

u/Imaginary__Bar 3h ago

It depends on the job.

As an interviewing manager for analysts I'm more interested in the approach to a problem rather than remembering the exact syntax of a query so I might whiteboard a problem with the candidates for 30-45 minutes.

We'd definitely cover order-of-operations, string/date manipulation, joins, subqueries/ctes, views & materialisation and if you get stuck just explain it in plain language".

Hiring someone as a DBA or a data engineer is similar, but I'd expect a greater level of autopilot from them.

2

u/nicopassaglia 3h ago

It depends on the role, but the questions cluster into a handful of types, roughly in this order of how often they come up:

  1. Filter, group, count. WHERE vs HAVING, GROUP BY with a condition on the total. Looks basic, and it's where people get eliminated early.
  2. Joins, especially LEFT JOIN to find what's missing ("customers with no orders") and counting after a join without double counting.
  3. The classics: second highest salary, find duplicates, top earner per department, employees who earn more than their manager (a self join).
  4. Window functions: ranking with ties (RANK vs DENSE_RANK vs ROW_NUMBER), running totals, compare with the previous row using LAG. More common for analyst and data roles than for general backend ones.
  5. Business questions for analysts: revenue per month, month-over-month change, retention, a funnel. Same SQL, but you have to turn a vague sentence into a query.

What they're really checking in most of these is the edge cases: what happens with ties, with NULLs, with a customer who appears twice. Saying "this breaks if two people share the top salary, so I'd use DISTINCT" out loud is worth more than writing the query fast.

If you want to practice that set: I built a free page with 12 of these to solve in the browser, each checked on a real database and with the trap explained. No sign-up. https://getsheetdrill.com/sql/interview-questions

Disclosure, it's my project. The questions are the well-known types, not taken from any company's list.

1

u/BigRossatron 1h ago

I have only been asked SQL questions twice that I remember in over 15 years and one of those was 'can you do joins?' the other time they wanted me to explain how I checked and cleansed some data as a follow up to another question.

I have been asked a few times pre-interview to submit some daily SQL queries that I often write from scratch.