Interview prep
Data Analyst SQL Interview Questions
SQL is tested in almost every data analyst interview, usually as a live exercise on tables like customers, orders and payments. Below are real interview-style questions grouped by what interviewers test. Each one runs on a real database, so you can practise writing the query, not just reading the answer.
1. Aggregation and GROUP BY questions
The most common category. Expect revenue by month, average order value per customer segment, or counts with a HAVING filter. Interviewers check that you group by the right columns and filter in the right place.
- Categories with Many ProductsecommerceMedium
- Customer Count by Age GroupfinanceMedium
- Visit Count by Month and YearhealthcareMedium
- Monthly Order CountecommerceMedium
- Deposit Volume by Day of WeekfinanceMedium
- Patients with More Than 3 VisitshealthcareMedium
- Average Rating Per ProductecommerceMedium
- Average Loan Principal by Loan TypefinanceMedium
2. JOIN questions
Combining customers, orders and products. The classic: find customers who never placed an order. Know when a LEFT JOIN is needed and how joins can duplicate rows.
- Customers Who Never OrderedecommerceMedium
- Customer Account ListfinanceMedium
- Visits with Patient NameshealthcareMedium
- Order Items with Full DetailsecommerceMedium
- Customers with No AccountsfinanceMedium
- Doctors with Department NameshealthcareMedium
- Orders with Payment and Shipping StatusecommerceMedium
- Transaction Details with Customer InfofinanceMedium
3. Subquery and CTE questions
Multi-step questions: compare each row with an average, find the second-highest value, or build a result in stages. Clear CTEs make your reasoning easy to follow.
- Products Priced Above AverageecommerceMedium
- Accounts with Above-Average BalancefinanceMedium
- Doctors Earning Above AveragehealthcareMedium
- High-Spending CustomersecommerceMedium
- Customers with Multiple Account TypesfinanceMedium
- Patients Who Have Never VisitedhealthcareMedium
- Most Expensive Product Per CategoryecommerceMedium
- Largest Transaction Per AccountfinanceMedium
4. Window function questions
Top N per group, running totals, ranking with ties, month-over-month growth with LAG. The topic that most often separates strong candidates.
- Rank Products by Price Within CategoryecommerceMedium
- Cumulative Loan Disbursements by MonthfinanceMedium
- Rank Doctors by Salary Within SpecialtyhealthcareMedium
- Customer Order Sequence NumbersecommerceMedium
- Rank Accounts by Balance Within TypefinanceHard
- Cumulative Billing ReporthealthcareMedium
- Rank Products by Revenue Within CategoryecommerceMedium
- Running Transaction Total Per AccountfinanceHard
5. Business case questions
Open problems like churn, retention, cohorts or funnel drop-off. There's no single keyword to spot. You choose the approach and explain it.
- Each Customer's Most Recent Order AmountecommerceMedium
- Combined Cash Inflow ReportfinanceMedium
- Prescription Duration in DayshealthcareMedium
- Average Days to Ship by StatusecommerceMedium
- Average Days Between Loan PaymentsfinanceMedium
- Visit Status Summary with CASEhealthcareMedium
- Product Pairs in the Same CategoryecommerceMedium
- Monthly Deposits vs WithdrawalsfinanceHard
How to answer a SQL interview question
1. Restate the question
Say what you think is being asked and which tables you'll need.
2. Clarify the edge cases
Do cancelled orders count? What about ties, NULLs or customers with no activity?
3. Plan in steps
Outline the query (filter, join, group, rank) before typing. CTEs make the plan visible.
4. Write and run it
Build the query one step at a time and look at the intermediate results.
5. Sanity-check the answer
Does the row count make sense? Would a stakeholder trust this number?
FAQ
- What SQL questions are asked in data analyst interviews?
- Mostly aggregations with GROUP BY and HAVING, JOINs (especially finding rows with no match), subqueries and CTEs for multi-step logic, and window functions for rankings, top N per group, running totals and period-over-period change. Senior roles add open business cases like retention or cohorts.
- How should I prepare for a SQL interview?
- Practise on realistic tables rather than memorising syntax. Solve a few questions per topic, then mix them. For each answer, say your assumptions out loud and check the result. Timed practice on medium and hard questions is the closest thing to the real interview.
- Which SQL dialect do interviews use?
- Usually standard SQL that works in PostgreSQL, MySQL, SQLite or BigQuery with small changes. The concepts (joins, grouping, window functions) are the same everywhere; only date functions differ much between databases.
- Are these interview questions free?
- Yes. With a free Google sign-in you can solve 10 new problems every week. SQLSolve Pro unlocks every problem, the reference solutions and unlimited AI hints.
Practise like it's the real interview
412 questions on real e-commerce, finance and healthcare data. Free to start.
Start practising