โก Short answer
Data analyst SQL interviews focus on SELECT and filtering, JOINs, GROUP BY with HAVING, subqueries, CTEs and window functions such as ROW_NUMBER, RANK and LAG. Expect to write 2โ4 queries live, so practise on real tables without autocomplete.
Topics by level
What gets tested at each level
Fresher interviews stay mostly in the first two rows; experienced roles go deeper.
Level
Topics
Typical for
Basic
SELECT, WHERE, ORDER BY, DISTINCT, aggregates, GROUP BY
All fresher roles
Intermediate
JOINs, HAVING, subqueries, CASE, CTEs, NULL handling
Data analyst, reporting analyst
Advanced
Window functions, running totals, indexing, optimisation
Senior analyst, BI and SQL developer
Basic questions
Basic SQL interview questions
Get these perfect. Interviewers use them to judge your fundamentals in the first five minutes.
Basic
What is the order of execution of a SQL query?
FROM/JOIN โ WHERE โ GROUP BY โ HAVING โ SELECT โ DISTINCT โ ORDER BY โ LIMIT. This explains why aliases from SELECT can't be used in WHERE.
Basic
DELETE vs TRUNCATE vs DROP?
DELETE removes chosen rows and can be filtered; TRUNCATE removes all rows quickly; DROP removes the whole table and its structure.
Basic
What is a primary key vs a foreign key?
A primary key uniquely identifies each row; a foreign key references a primary key in another table to link them.
Basic
COUNT(*) vs COUNT(column)?
COUNT(*) counts all rows; COUNT(column) counts only rows where that column is not NULL.
Basic
What does DISTINCT do?
It removes duplicate rows from the result based on the selected columns.
Basic
How do you handle NULLs?
Use IS NULL / IS NOT NULL to filter, and COALESCE to replace NULL with a default value. NULL = NULL is never true.
Intermediate questions
Intermediate SQL interview questions
This is where most data analyst interviews spend their time.
Joins
How does a LEFT JOIN create NULLs?
Rows in the left table with no match on the right still appear, with NULLs in the right table's columns. Useful for finding "customers with no orders".
Joins
What is a self join?
Joining a table to itself with aliases, for example to match employees with their managers in the same table.
Grouping
Find departments with more than 10 employees.
GROUP BY department, then HAVING COUNT(*) > 10. WHERE cannot filter on an aggregate.
Subqueries
Correlated vs non-correlated subquery?
A non-correlated subquery runs once; a correlated one references the outer query and runs per row, so it can be slower.
Logic
How do you use CASE WHEN?
To create conditional columns, such as bucketing customers into High, Medium and Low spenders, or for conditional aggregation.
Sets
UNION vs UNION ALL?
UNION removes duplicates (slower); UNION ALL keeps every row (faster). Use UNION ALL unless you need de-duplication.
Knowing answers is half the job; writing queries under time pressure is the other half. Practise with a trainer.
Book a free demoAdvanced questions
Advanced SQL and window function questions
Window functions are the single biggest differentiator in analyst SQL rounds.
Window
What is a window function?
A function that calculates across a set of related rows using OVER (PARTITION BY โฆ ORDER BY โฆ) without collapsing rows like GROUP BY does.
Window
How do you calculate a running total?
SUM(amount) OVER (ORDER BY order_date) gives a running total; add PARTITION BY customer_id for a running total per customer.
Window
What do LAG and LEAD do?
They read the previous or next row's value, which is perfect for month-over-month growth or the time between orders.
Performance
How would you speed up a slow query?
Check the execution plan, add indexes on join and filter columns, avoid SELECT *, filter early and replace repeated subqueries with CTEs or joins.
Query practice
Queries you may be asked to write live
Know the pattern for each of these and you can handle most live rounds.
Task
Pattern to use
Top 3 products by revenue in each category
DENSE_RANK() OVER (PARTITION BY category ORDER BY revenue DESC), then filter rank โค 3
Customers who never placed an order
LEFT JOIN orders and filter where the order id IS NULL (or NOT EXISTS)
Month-over-month revenue growth
Aggregate by month in a CTE, then LAG(revenue) to compare with the previous month
Delete duplicate rows but keep one
ROW_NUMBER() OVER (PARTITION BY duplicate columns), keep row_number = 1
Employees earning more than their manager
Self join employees e to employees m on e.manager_id = m.id where e.salary > m.salary
๐ก Practise each pattern on a sample database such as AdventureWorks. Our SQL course in Hyderabad drills these daily.
Live round tips
How to handle a live SQL round
Interviewers care as much about how you think as about the final query.
01
Clarify the question
Ask about table structure, duplicates, NULLs and ties before you write anything.
02
Think out loud
Explain your plan: which tables to join, how to group and how to filter.
03
Build step by step
Start simple, check the output, then add joins, grouping or window functions.
04
Test edge cases
Mention how your query handles NULLs, ties and empty results.
โ Jumping straight into code without understanding the tables.
โ Using SELECT * and GROUP BY on columns you don't need.
โ Staying silent when stuck. Talk through your approach; partial credit is real.
FAQs
SQL interview questions, answered
Which SQL database should I practise on?
MySQL, PostgreSQL or SQL Server are all fine. Core syntax is very similar; companies care that you know the concepts.
Are window functions asked in fresher interviews?
Increasingly, yes. ROW_NUMBER, RANK and running totals now appear even in fresher rounds at many companies.
How many SQL problems should I practise?
Aim for 50โ100 varied problems covering joins, grouping, subqueries and window functions, rather than repeating easy ones.
Is SQL enough to get a data analyst job?
SQL is the most important skill, but most roles also expect Excel and a BI tool such as Power BI.
How long does it take to learn SQL for interviews?
About 4โ6 weeks of daily practice gets most learners interview-ready for analyst roles.
Do you offer a standalone SQL course?
Yes. Our 30-day SQL course costs โน25,000 classroom or โน20,000 online. SQL is also part of the full data analytics program.