Data analyst interviews in India commonly include an SQL round, whether a live coding exercise, a take-home test or a whiteboard discussion. The questions are rarely exotic. They test whether you can turn a business question into a correct query and explain your logic. This guide lists the questions that come up most often, grouped by difficulty, with notes on what the interviewer is really checking.
Technical details in this article were checked against the official PostgreSQL documentation in October 2026. Syntax can vary slightly between databases.
How analyst SQL rounds usually work
Formats vary by company, but you will commonly meet one or more of these:
- Live coding on a shared editor or a platform, with two to four questions in 30 to 60 minutes.
- Take-home exercise with a small dataset and a set of business questions.
- Discussion round where you explain how you would write a query, without running it.
In every format, talk through your thinking. Interviewers care about how you handle ambiguity and edge cases as much as the final query.
Basic questions (fresher level)
- What is the difference between WHERE and HAVING? (WHERE filters rows before grouping; HAVING filters groups after aggregation.)
- Explain INNER, LEFT, RIGHT and FULL OUTER joins with an example.
- What is the difference between UNION and UNION ALL? (UNION removes duplicates; UNION ALL keeps them and is usually faster.)
- How do you find duplicate rows in a table? (GROUP BY the relevant columns with HAVING COUNT(*) greater than 1.)
- What is the difference between COUNT(*), COUNT(column) and COUNT(DISTINCT column)?
- How does NULL behave in comparisons and aggregates? (NULL is not equal to anything, including NULL; most aggregates ignore NULLs.)
- What is the logical order in which a SELECT query is processed? (Roughly FROM and JOIN, WHERE, GROUP BY, HAVING, SELECT, ORDER BY, then LIMIT.)
- What is a primary key, and what is a foreign key?
Intermediate questions (1–3 years)
- Find the second-highest salary in each department.
- Find customers who placed an order in January but not in February.
- Calculate month-over-month revenue growth.
- What is a CTE and when would you use one instead of a subquery?
- Write a query using CASE WHEN to bucket customers into spending tiers.
- Explain the difference between ROW_NUMBER, RANK and DENSE_RANK.
- Calculate a running total of sales by date.
- Find the top three products by revenue in each category.
- What happens to row counts when you join a table with duplicates on the join key? (Rows multiply, a common cause of inflated totals.)
Advanced questions (3+ years or senior roles)
- Use LAG or LEAD to find the gap in days between a customer’s consecutive orders.
- Calculate a seven-day moving average of daily active users.
- Find users who logged in on three or more consecutive days.
- Build a simple cohort retention table: users grouped by sign-up month, with the share active in each later month.
- Calculate a funnel conversion rate from page view to add-to-cart to purchase.
- How would you deduplicate a table, keeping only the latest record per customer?
- What is the difference between a correlated subquery and a window function for the same problem, and which is usually clearer?
- How would you check whether a query that runs slowly could be improved? (Look at the execution plan, filter early, avoid unnecessary DISTINCT, check indexes or partitioning.)
Window functions: the topic that separates candidates
Questions 14 to 21 all rely on window functions. The PostgreSQL documentation describes a window function as performing a calculation across a set of table rows that are somehow related to the current row, without collapsing them into a single output row the way GROUP BY does. That is the key idea to explain in an interview.
Make sure you can explain and write:
PARTITION BY, which defines the groups.ORDER BYinside OVER(), which defines the order within each group.- Frame clauses such as
ROWS BETWEEN 6 PRECEDING AND CURRENT ROWfor moving averages. - Ranking functions, and LAG and LEAD for comparisons with previous or next rows.
How to answer any SQL question well
- Restate the question and confirm assumptions: “Should ties count as the same rank?” “Are cancelled orders included?”
- Describe the tables you need and how they join.
- Write the query in steps, using CTEs to keep it readable.
- Check edge cases: NULLs, duplicates, ties, empty months and time zones.
- Sanity-check the result: “This should return one row per customer; let me confirm the count.”
The case round: SQL plus business thinking
Many analyst interviews include a case question such as “Orders dropped 15% last week. How would you investigate?” There is no single right answer. Interviewers want to see structure.
A simple framework:
- Clarify the metric. Orders placed or completed? Compared with last week or the same week last year?
- Check the data first. Was there a tracking change, a pipeline failure or a reporting delay?
- Segment. Break the drop down by city, platform, channel, new versus returning customers and product category.
- Look for external causes. Festivals, holidays, competitor sales, weather or price changes.
- Form hypotheses and say which data would test each one. This is where you mention the SQL you would write.
- Recommend next steps and what you would monitor.
Practise this aloud with Indian business examples: a food delivery app, a bank’s credit card spends, an e-commerce sale event or a telecom’s recharge data.
A two-week practice plan
- Days 1–3: Joins, GROUP BY, HAVING and NULL handling on a sample database.
- Days 4–7: CTEs, CASE WHEN and date functions.
- Days 8–11: Window functions: ranking, running totals, LAG and LEAD, moving averages.
- Days 12–14: Mock interviews with a friend, including two case questions spoken aloud.
Frequently asked questions
Which SQL dialect should I practise for interviews?
Most interview questions use standard SQL that works in PostgreSQL, MySQL 8, SQL Server and cloud warehouses with minor changes. PostgreSQL or MySQL are good choices for practice. Ask the recruiter which database the team uses.
Are window functions really asked in fresher interviews?
They are more common for experienced roles, but basic ranking with ROW_NUMBER or RANK can appear in fresher rounds too. Learning them early gives you an advantage.
Can I use AI tools during an SQL interview?
Unless the interviewer explicitly allows it, assume you cannot. Separately, practise reviewing and fixing AI-generated SQL, since checking such queries is increasingly part of day-to-day analyst work.
Official sources
- PostgreSQL documentation: Window functions tutorial
- PostgreSQL documentation: Window function calls (syntax and frame clauses)
- PostgreSQL documentation: SELECT

Leave a Reply