← Create New Paste

SQL Interview Questions for Analysts: Patterns Worth Mastering

4 views
SQL rounds for data analyst and analytics engineer roles tend to repeat a handful of patterns. If you can recognise them quickly and explain your approach, you will handle most questions comfortably, even unfamiliar ones. 1. Aggregation with filtering "Find customers who placed more than three orders last month." The key is knowing the difference between WHERE (filters rows before grouping) and HAVING (filters groups after aggregation). Say this out loud; interviewers listen for it. 2. Joins and missing data "List all products, including those that have never been sold." This tests LEFT JOIN plus handling NULLs, often with COALESCE. Be ready to explain why an INNER JOIN would silently drop rows, and to spot duplicate rows caused by joining on a non-unique key. 3. Ranking and top-N per group "Return the top two salespeople in each region." Window functions such as ROW_NUMBER, RANK and DENSE_RANK with PARTITION BY are the clean solution. Explain how ties are handled by each function, because that is a common follow-up. 4. Running totals and period-over-period change "Show cumulative revenue by day" or "month-over-month growth." Use SUM() OVER (ORDER BY date) and LAG(). Mention date truncation and what happens when a month has no data. 5. Deduplication "Keep only the latest record for each user." A ROW_NUMBER over PARTITION BY user_id ORDER BY updated_at DESC, filtered to 1, is the standard answer. It also appears in data cleaning discussions. 6. Funnels and retention "What percentage of sign-ups made a purchase within seven days?" Break it into steps with CTEs: sign-ups, first purchases, then a join on user and date difference. Clear CTE names make your logic easy to follow. How to answer well - Clarify the schema and edge cases first: time zones, duplicates, NULLs. - Write readable SQL with CTEs instead of deeply nested subqueries. - Check your result with a tiny mental example. - Mention performance briefly: indexes on join keys, filtering early, avoiding SELECT *. Practise with real data Load a public dataset into SQLite or Postgres and write each pattern from memory twice a week. Explaining your query to a friend is the best test of whether you truly understand it. During live rounds, staying calm matters as much as syntax. Linkjob AI (https://linkjob.ai) offers real-time help during live job interviews and technical interviews, which some analysts use to keep their reasoning organised. Combined with steady practice on these six patterns, it can make SQL interviews feel far less intimidating.
Created Nov 13, 2026 08:55 Expires Nov 13, 2027 08:55