SQL is still the single most-tested skill in every data analyst interview in 2025 — and if you can't write a clean GROUP BY or explain the difference between a CTE and a subquery under pressure, the job is going to someone who can.
Why SQL Remains the Core of Every Data Analyst Interview
Data tooling has evolved dramatically over the past few years. Companies now run dbt pipelines, Snowflake warehouses, and Looker dashboards. Yet when Google, Amazon, Meta, Microsoft, and Stripe sit down to hire a data analyst, the first technical screen is almost always SQL. The reason is deceptively simple: SQL is the language of data truth. It forces candidates to demonstrate logical thinking, attention to detail, and the ability to translate a business question into a precise, reproducible query.
A 2024 LinkedIn Talent Insights report found that SQL was the most requested skill across all data-related job postings in the US, UK, Canada, and Australia — ahead of Python, Tableau, and Excel. If you are preparing for a data analyst role at any company in 2025, your SQL preparation is not optional; it is the foundation everything else rests on.
This guide covers the SQL interview questions that are actually being asked right now, from entry-level analyst roles at mid-size companies to senior positions at Big Tech. We'll walk through the categories, example questions, model answers, and the strategic thinking interviewers want to see behind every query.
How to Structure Your SQL Interview Preparation
Before diving into specific questions, understand the three tiers every interviewer is testing:
- Foundational SQL: SELECT, WHERE, GROUP BY, HAVING, ORDER BY, JOINs, and basic aggregation functions.
- Intermediate SQL: Subqueries, CTEs (Common Table Expressions), CASE statements, date manipulation, and string functions.
- Advanced SQL: Window functions, query optimisation, indexing concepts, and analytical problem-solving patterns.
Most interviews at companies like Shopify or Stripe will push into the intermediate-to-advanced tier within the first 20 minutes. For roles at earlier-stage startups, a solid command of foundational SQL with clean, readable code is often enough to stand out. Know which tier the role demands and prepare accordingly.
One of the most underrated preparation moves: make sure your resume explicitly lists the SQL skills you have and the databases you've worked in (PostgreSQL, MySQL, BigQuery, Redshift, Snowflake). If you want to build your free ATS resume that properly highlights your technical stack, start there before you even open a LeetCode problem.
Foundational SQL Interview Questions
1. What is the difference between WHERE and HAVING?
WHERE filters rows before aggregation occurs. HAVING filters after aggregation. This is a classic trap question because candidates confuse them under pressure.
Example: "Find all product categories where the total revenue exceeded $50,000 last quarter." You cannot use WHERE here because total revenue is an aggregate. The correct approach uses GROUP BY with a HAVING clause filtering on SUM(revenue) > 50000.
Interviewers at Amazon and Microsoft use this question not just to test syntax knowledge but to see if you understand why the distinction exists — it reflects how the SQL engine processes queries sequentially.
2. Explain the different types of JOINs.
This is asked in virtually every SQL interview for data analysts in 2025. A complete answer covers:
- INNER JOIN: Returns only rows with matching values in both tables.
- LEFT JOIN (LEFT OUTER JOIN): Returns all rows from the left table and matched rows from the right; unmatched right-side rows return NULL.
- RIGHT JOIN: The inverse of LEFT JOIN.
- FULL OUTER JOIN: Returns all rows from both tables, with NULLs where there is no match.
- CROSS JOIN: Returns the Cartesian product of both tables — every row from the first paired with every row from the second.
- SELF JOIN: Joins a table to itself, useful for hierarchical data like employee-manager relationships.
Don't just define them. Be ready to write each one against a real schema. Interviewers at Meta often present a users table and an events table and ask which JOIN type would retain users who have never triggered any event — the answer is a LEFT JOIN on the users table.
3. What is the difference between COUNT(*), COUNT(column), and COUNT(DISTINCT column)?
- COUNT(*): Counts all rows, including those with NULL values.
- COUNT(column): Counts non-NULL values in the specified column.
- COUNT(DISTINCT column): Counts unique non-NULL values.
A data analyst who can articulate this distinction immediately demonstrates they think about data quality, not just syntax — which is exactly what hiring managers want to see.
Intermediate SQL Interview Questions
4. Write a query using a CTE to find the top 3 customers by revenue per region.
CTEs (Common Table Expressions) are a non-negotiable topic in 2025 SQL interviews. They improve readability and allow you to break complex logic into named, reusable blocks. A model answer would:
- Use a first CTE to aggregate total revenue per customer per region.
- Use a second CTE (or window function) to rank customers within each region using ROW_NUMBER() or RANK().
- Filter the outer query to WHERE rank <= 3.
The key signal interviewers look for is whether you instinctively reach for a CTE rather than a deeply nested subquery. Nested subqueries are harder to debug and maintain — clean CTE usage is a professional coding habit that separates candidates who have worked in production environments from those who have only practiced on toy datasets.
5. How would you identify duplicate rows in a table?
This is a real-world data quality problem every analyst faces. The standard SQL pattern uses GROUP BY on the columns that define uniqueness and a HAVING COUNT(*) > 1 clause. A stronger answer also discusses how you would handle or remove duplicates: using ROW_NUMBER() in a CTE to assign a sequence and then deleting or filtering rows where the sequence number is greater than 1.
6. Write a query to calculate a 7-day rolling average of daily sign-ups.
This question bridges intermediate and advanced SQL and is a favourite at product-analytics-heavy companies like Airbnb, Uber, and Stripe. It requires:
- A date-spine or a base query grouping sign-ups by day.
- A window function: AVG(daily_signups) OVER (ORDER BY date ROWS BETWEEN 6 PRECEDING AND CURRENT ROW).
Candidates who can write this fluently — and explain what ROWS BETWEEN means — immediately stand out. It signals that you think about data as a time series, which is central to product analytics work.
Advanced SQL Interview Questions — Window Functions
Window functions are the single biggest differentiator in data analyst SQL interviews in 2025. If you are interviewing for any mid-to-senior analyst role, you must be fluent in RANK(), DENSE_RANK(), ROW_NUMBER(), LAG(), LEAD(), SUM() OVER, and NTILE().
7. What is the difference between RANK() and DENSE_RANK()?
Both assign a rank to rows within a partition, but they handle ties differently. RANK() leaves gaps after a tie (1, 2, 2, 4), while DENSE_RANK() does not (1, 2, 2, 3). The correct choice depends on the business requirement — if you are finding the "top N" and gaps in ranking matter, DENSE_RANK() is usually more appropriate for analyst use cases.
8. Use LAG() to calculate month-over-month revenue growth.
This is an extremely common interview question at e-commerce and SaaS companies. The solution requires LAG(revenue, 1) OVER (ORDER BY month) to pull the previous month's revenue into the current row, then calculate ((current - previous) / previous) * 100 as the growth rate. Interviewers specifically watch to see how you handle the first row where LAG() returns NULL — a complete answer addresses this edge case explicitly.
9. Explain PARTITION BY vs GROUP BY.
GROUP BY collapses rows into a single result per group. PARTITION BY (used inside window functions) preserves all original rows while adding aggregate or ranking calculations alongside them. This distinction is critical for analytical queries where you need row-level detail alongside group-level context — for example, showing each employee's salary next to the average salary for their department, without losing individual employee rows.
Scenario-Based and Business Logic SQL Questions
In 2025, top companies are moving away from pure syntax drills toward scenario-based SQL questions that test analytical thinking. These questions describe a business problem and ask you to design a query from scratch.
10. "We have a sessions table and a purchases table. How would you calculate the conversion rate by marketing channel?"
This is the kind of open-ended question Shopify, HubSpot, and Salesforce ask. There is no single right answer — but a strong response will:
- Clarify assumptions (is one session per user per day, or multiple sessions allowed?).
- Choose the correct JOIN type (LEFT JOIN from sessions to purchases to preserve sessions without a purchase).
- Aggregate: COUNT(DISTINCT purchase_id) / COUNT(DISTINCT session_id) per channel.
- Handle potential date-range filtering and NULL purchases explicitly.
Before your interview, use a tool to extract job keywords from the actual job description. Companies embed their data stack and analytical focus areas directly into postings — if the JD mentions "funnel analysis" or "cohort retention," you can bet scenario questions will reflect those themes.
11. Find users who made a purchase in January but not in February (Retention / Churn Analysis)
This tests your ability to use a LEFT JOIN with a NULL filter or a NOT EXISTS / NOT IN pattern. It's a churn analysis staple at subscription businesses like Netflix, Spotify, and Duolingo. The cleanest solution uses a LEFT JOIN from January purchasers to February purchasers on user_id, then filters WHERE february_user_id IS NULL.
Common SQL Mistakes That Cost Candidates the Job
After years of coaching candidates through technical interviews, here are the most frequent SQL mistakes I see that sink otherwise strong candidates:
- Forgetting NULLs: NULL is not zero and not an empty string. Aggregations ignore NULLs by default. Joins on NULL columns never match. Always ask yourself how your query handles NULL values.
- Unreadable formatting: Interviewers read your code. Use consistent indentation, uppercase SQL keywords, and alias your tables clearly (e.g., o for orders, c for customers).
- Ignoring performance: For senior roles, discussing WHY a query is efficient (or not) matters as much as getting the right result. Mention indexing, avoiding SELECT *, and filtering early.
- Not asking clarifying questions: Real data is messy. Asking "Should I assume user_id is unique per row in this table?" signals professional maturity.
- Jumping to the answer: Think out loud. Interviewers want to see your reasoning process, not just the final query.
How to Practice SQL for Interviews in 2025
The best SQL preparation is a combination of structured problem-solving and hands-on writing. Here is the regimen I recommend to candidates across all experience levels:
- LeetCode SQL (Database section): Focus on Medium and Hard problems. The top 50 most-asked questions cover the majority of real interview scenarios.
- Mode Analytics SQL Tutorial: Excellent for understanding real analytical query patterns on real-world-style data.
- DataLemur: Purpose-built for data analyst and data scientist SQL interviews, with questions sourced from actual FAANG interviews.
- Write queries by hand: Don't just read solutions. Type every query yourself, run it, break it, and fix it.
- Mock interviews: Use Pramp or Interviewing.io for live SQL mock sessions where someone is watching you think in real time.
On the application side, make sure your resume clearly reflects the SQL depth you have built. Browse ATS resume templates designed specifically for data and analytics roles — a well-formatted technical resume ensures your SQL skills are seen before you even reach the interview stage.
Regional Considerations for SQL Interviews
While SQL fundamentals are universal, the interview style varies by market:
- United States: Expect heavy emphasis on window functions, optimisation, and scenario-based business problems. FAANG-style companies run multiple SQL rounds with progressively harder questions.
- United Kingdom: SQL interviews tend to be more conversational, often paired with a take-home case study. Clean, well-commented queries matter as much as correctness.
- Canada (Toronto / Vancouver tech hubs): Shopify, Hootsuite, and the Canadian bank tech divisions test SQL heavily alongside Python. Expect questions on time-series and financial aggregations.
- Australia: Government and finance sector analyst roles often focus on reporting-oriented SQL (complex GROUP BY, ROLLUP, CUBE). Startup roles mirror US-style interviews.
Build your free ATS resume and make sure your SQL expertise gets noticed before you even step into the interview room.
Conclusion
SQL remains the most critical technical skill for data analyst interviews in 2025, and the candidates who win offers are those who combine syntactic fluency with genuine analytical thinking — they don't just write queries, they explain the business logic behind every line. Focus your preparation on the three tiers: foundational queries, intermediate patterns like CTEs and CASE statements, and advanced window functions that separate good analysts from great ones. Practice with realistic scenario-based questions, never ignore NULL handling, and always think out loud during the interview. With the right preparation and a resume that positions your SQL skills clearly, you will walk into every data analyst interview in 2025 with genuine confidence.
Tags
Resume Builder Team
Career experts and former recruiters helping job seekers worldwide build stronger resumes and land roles at top companies.