Get access to 100+ SQL interview questions, real-world query challenges, SQL cheat sheets, and prep guides tailored for every role and experience level.
SQL questions for data analysts often focus on real-world business problems like calculating aggregates, filtering data, joining multiple tables, and ranking rows. Common question types include:
1. Finding top N values with LIMIT, RANK(), or ROW_NUMBER()
2. Identifying NULLs or unmatched rows using LEFT JOIN or NOT EXISTS
3. Writing complex GROUP BY queries with HAVING
Use real datasets like AdventureWorks or public datasets from Kaggle or Baselight. Focus on writing queries from scratch to solve prompts like “find customers who haven’t placed an order,” or “calculate month-over-month revenue.”
Books like Real SQL Queries and platforms like Galaxy, Mode, or LeetCode are great for hands-on preparation.
Build a project using public data (e.g., NYC taxi data), write meaningful queries, and host your results in a notebook (like Hex, Jupyter, or Galaxy). Be prepared to talk about your approach, the SQL you wrote, and what insights you uncovered. Recruiters love seeing initiative and practical application.
You should know how to use INNER JOIN, LEFT JOIN, and SELF JOIN. In more advanced cases, expect to explain or write FULL OUTER JOIN, anti-joins using NOT EXISTS, and even CROSS APPLY or EXCEPT in SQL Server roles.
- Misplacing filters between WHERE and HAVING
- Forgetting to group by all non-aggregated columns
- Using = instead of IN or LIKE for subqueries
- Writing subqueries where a join would be better
- Not testing for NULL values with IS NULL
- Write a query to return all users with no orders
- Calculate total revenue per month from an orders table
- What is the difference between WHERE and HAVING?
- Explain what a JOIN is and why it’s used
- Show all customers who made more than two purchases in a week
The AdventureWorks2022 database is widely used in technical interview prep, especially for Microsoft stack roles.
Other useful options include:
- NYC Open Data
- COVID-19 datasets
- Online retail transaction logs (via Kaggle)
Vibe code in SQL using AI that is context-aware for query generation, optimization, and notifications when your data model changes.
Check outLeverage Galaxy's best-in-class SQL editor to write and optimize your queries, in a fast-lightweight query client that doesn't crash.
Check out