SQL interview questions for data analysts

Write queries on grocery delivery data: orders, customers, events and payments. Each question includes input tables and expected output. Open the exercise to run PostgreSQL in your browser and check your answer, free without an account.

20 questions · Easy to hard · PostgreSQL in your browser

Easy SQL questions

Medium SQL questions

Hard SQL questions

How to practice for your interview

  1. Start with an easy question. State what one output row represents before choosing joins and aggregates.
  2. Move to medium questions for ranking, running totals and date logic. Check ties, missing rows and period boundaries against the example.
  3. Try a hard question or a query to fix. Explain where a join could multiply rows and how you would verify the result.

Check more than the sample

Compare the output columns and values first. Then add a case the example does not cover: a NULL, a tied value or a customer with no matching order.

Read the shared data rules for dates, delivered orders and output conventions.

More interview practice

All interview questions