SQL for Data Analysis Questions

Writing SQL to answer analytical and business questions. Covers filtering, joins, grouping and aggregation, subqueries, CTEs, and translating an ambiguous request into a correct query. Includes spreadsheet-to-SQL fluency for everyday analyst workflows.

EasyTechnical
71 practiced

Write a query to find customers who have never placed an order. Given customers(customer_id, email) and orders(order_id, customer_id), return customer_id and email for every customer with zero matching orders.

MediumTechnical
60 practiced

You're given three related tables at different granularities (say users, sessions, and events). Write a query that answers a business question spanning all three (for example: number of distinct users with at least one event in a session in the last 30 days), and explain how you chose the join order and join types.

HardTechnical
98 practiced

Not every company's reporting period lines up with the calendar month. Given a transactions table and a fiscal_calendar lookup table mapping calendar dates to fiscal year/month, write a query that aggregates revenue by fiscal period, and explain why you'd model this as a join to a calendar table rather than date arithmetic.

EasyTechnical
78 practiced

What's the difference between GROUP BY and DISTINCT? Give an example of each, and show a case where you need HAVING on top of a GROUP BY versus a case where a plain DISTINCT is all you need.

EasyTechnical
62 practiced

Write a query that computes Daily Active Users (DAU) for a given month: for each date, the count of distinct users with at least one event that day.

Unlock Full Question Bank

Get access to all SQL for Data Analysis interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.