If you are preparing for a data analyst role in India, mastering SQL interview questions is not optional — it is the single most important thing standing between you and your dream offer at companies like TCS, Infosys, Flipkart, or Swiggy.
Why SQL Is the Most Critical Skill for Data Analysts in India
Walk into any data analyst interview in Bengaluru, Hyderabad, Pune, or Mumbai and the first technical round will almost certainly open with SQL. Hiring managers at Indian product companies and IT services firms consistently rank SQL proficiency as their top screening criterion — above Python, above Excel, and sometimes even above domain knowledge. According to multiple job postings on Naukri.com and LinkedIn India, over 80 percent of data analyst job descriptions explicitly list SQL as a mandatory skill.
The reason is simple. Whether a company runs its analytics on a MySQL database at a mid-sized startup or on Redshift at a large enterprise, analysts spend the majority of their working hours writing queries, debugging them, and communicating results to business stakeholders. If you cannot write a clean GROUP BY query or debug a broken JOIN, you will struggle from day one.
This guide covers the most commonly asked SQL interview questions for data analyst roles in India, organized from foundational concepts all the way to advanced problem-solving. Real-world context from Indian companies has been woven throughout so that you understand not just how to answer a question but why it matters on the job.
Understanding the Interview Structure at Indian Companies
Before diving into the questions themselves, it helps to understand how Indian companies structure their data analyst technical interviews.
- IT Services Giants (TCS, Infosys, Wipro, Cognizant, HCL): These firms typically run two to three rounds. The first is an online assessment with multiple-choice SQL questions and sometimes a coding challenge on platforms like HackerEarth or HackerRank. The second round is a technical interview where you write queries on a whiteboard or shared screen.
- Product and E-commerce Companies (Flipkart, Swiggy, Zomato, Meesho, Razorpay): Expect a live SQL coding round, often on a shared IDE or Google Docs. Questions are scenario-based — for example, "Given our orders table, find the top 5 cities by revenue last quarter."
- Analytics and Consulting Firms (Mu Sigma, LatentView, Tiger Analytics): These firms focus heavily on problem-solving. They may give you a messy dataset and ask you to clean and analyse it using SQL.
- Banking and BFSI (HDFC, ICICI, Kotak): SQL questions here often revolve around transactional data, date functions, and window functions for running totals and period comparisons.
Basic SQL Interview Questions for Data Analyst Freshers
If you are a fresher or have less than one year of experience, expect interviewers to test your fundamentals thoroughly. Do not underestimate these questions — a surprising number of candidates stumble on basics during high-pressure interviews.
1. What is the difference between WHERE and HAVING?
WHERE filters rows before aggregation, while HAVING filters after aggregation. A classic mistake is using WHERE to filter on an aggregate function like COUNT or SUM — that is when you need HAVING instead.
Example context: Imagine you are working at Infosys and analysing support ticket data. If you want to find departments that have raised more than 50 tickets in a month, you cannot use WHERE on the count — you need HAVING COUNT(ticket_id) > 50.
2. Explain the different types of JOINs in SQL.
This is one of the most frequent SQL interview questions for data analyst candidates across all experience levels in India. You must know all four types fluently.
- INNER JOIN: Returns only rows where there is a match in both tables.
- LEFT JOIN (or LEFT OUTER JOIN): Returns all rows from the left table and matched rows from the right table; unmatched rows from the right return NULL.
- RIGHT JOIN: The mirror image of LEFT JOIN.
- FULL OUTER JOIN: Returns all rows from both tables, with NULLs where there is no match.
Real-world tip: At a company like Flipkart, you might join a customers table with an orders table. A LEFT JOIN ensures you see customers who have never placed an order — crucial for churn analysis.
3. What is the difference between DELETE, TRUNCATE, and DROP?
- DELETE: Removes specific rows based on a WHERE condition. It is a DML command and can be rolled back.
- TRUNCATE: Removes all rows from a table without logging individual row deletions. It is faster than DELETE and generally cannot be rolled back.
- DROP: Removes the entire table structure along with all data. This is a DDL command.
4. What are aggregate functions? Name five.
Aggregate functions perform calculations on a set of values and return a single value. The five you must know are COUNT, SUM, AVG, MIN, and MAX. These appear in virtually every data analyst SQL coding question across companies in India.
5. What is a NULL value and how do you handle it?
NULL represents the absence of a value, not zero or an empty string. To check for NULLs, always use IS NULL or IS NOT NULL — never = NULL. Functions like COALESCE and ISNULL help replace NULLs with default values during analysis.
Intermediate SQL Interview Questions for Data Analysts
Once the basics are covered, interviewers at mid-level data analyst roles — typically one to four years of experience — move into more nuanced territory. These questions test whether you can actually use SQL to solve real business problems.
6. Write a query to find the second highest salary in an employee table.
This is perhaps the single most asked SQL interview question for data analyst roles in India. There are multiple valid approaches, and knowing more than one demonstrates depth.
SELECT MAX(salary) FROM employees WHERE salary < (SELECT MAX(salary) FROM employees);
An alternative using DENSE_RANK is considered more elegant and scalable, which leads us perfectly into the next topic.
7. What are window functions and when do you use them?
Window functions perform calculations across a set of rows that are related to the current row, without collapsing the result into a single value the way GROUP BY does. They are game-changers for advanced data analyst SQL coding questions in India.
The most commonly tested window functions are:
- ROW_NUMBER(): Assigns a unique sequential number to each row within a partition.
- RANK() and DENSE_RANK(): Assign ranks with RANK skipping numbers after ties and DENSE_RANK not skipping.
- LAG() and LEAD(): Access data from a previous or subsequent row, extremely useful for month-over-month comparisons.
- SUM() OVER() / AVG() OVER(): Running totals and moving averages.
Example: A data analyst at Zomato might use LAG() to compare today's order volume with yesterday's order volume for each city, identifying sudden drops that could indicate a technical outage.
8. What is the difference between UNION and UNION ALL?
UNION combines results from two queries and removes duplicate rows. UNION ALL combines results and keeps all duplicates, making it faster. When analysing data from multiple regional databases — a common scenario at companies like Wipro that manage databases for different client geographies — UNION ALL is preferred when duplicates are not a concern and performance matters.
9. Explain subqueries vs Common Table Expressions (CTEs).
A subquery is a query nested inside another query. A CTE (using the WITH clause) is a named temporary result set that makes complex queries far more readable and maintainable. In modern data analyst technical interviews in India, demonstrating knowledge of CTEs signals that you write production-quality SQL rather than one-off scripts.
10. How do you find duplicate records in a table?
A classic analytical task. The standard approach is to use GROUP BY on the columns you suspect contain duplicates and then filter with HAVING COUNT(*) > 1.
SELECT email, COUNT(*) as cnt FROM users GROUP BY email HAVING COUNT(*) > 1;
This exact type of query is used regularly at companies like Meesho and Razorpay when cleaning customer registration data.
Advanced SQL Interview Questions for Experienced Data Analysts
Senior data analyst roles — typically four-plus years of experience — at companies like Cognizant, LatentView Analytics, or Mu Sigma will push your SQL skills to their limits. These questions test not just syntax but your ability to think algorithmically and optimise queries.
11. How do you optimise a slow-running SQL query?
This open-ended question has no single correct answer, which is exactly why interviewers love it. A strong response covers multiple angles:
- Use EXPLAIN or EXPLAIN ANALYZE to understand the query execution plan.
- Add appropriate indexes on columns used in WHERE, JOIN, and ORDER BY clauses.
- Avoid using SELECT * — retrieve only the columns you need.
- Replace correlated subqueries with JOINs or CTEs wherever possible.
- Avoid functions on indexed columns in WHERE clauses, as they prevent index usage.
- Partition large tables and leverage partition pruning.
12. Write a query to calculate a 7-day rolling average of sales.
This is a highly practical question for anyone interviewing at e-commerce or BFSI firms. It tests your understanding of window functions and frame clauses.
SELECT sale_date, daily_revenue, AVG(daily_revenue) OVER (ORDER BY sale_date ROWS BETWEEN 6 PRECEDING AND CURRENT ROW) AS rolling_7day_avg FROM daily_sales;
13. What are indexes and what are the trade-offs of using them?
An index is a database object that speeds up data retrieval at the cost of additional storage and slower write operations (INSERT, UPDATE, DELETE). In interviews, demonstrating awareness of this trade-off — not just the benefit — shows mature engineering thinking. A data analyst at an HDFC analytics team, for instance, would need to be careful about adding too many indexes on a high-frequency transactional table.
14. Explain the concept of normalization and its forms.
While normalization is more of a database design concept, data analysts are often asked about it because they work with existing schema designs and need to understand why data is structured the way it is.
- 1NF (First Normal Form): Each column contains atomic values; no repeating groups.
- 2NF (Second Normal Form): 1NF plus no partial dependencies on a composite key.
- 3NF (Third Normal Form): 2NF plus no transitive dependencies.
15. How would you identify and handle data skew in SQL?
Data skew occurs when certain partition keys have significantly more data than others, leading to uneven query performance. This question is especially relevant if you are interviewing for roles involving big data platforms like Hive or Spark SQL, which are increasingly common at large Indian tech firms. Solutions include salting skewed keys, using broadcast joins for small tables, and rewriting queries to avoid grouping on high-cardinality columns unnecessarily.
Scenario-Based SQL Questions from Real Indian Company Interviews
Many Indian companies, especially product startups, prefer scenario-based questions over abstract theoretical ones. Here are some you should prepare for thoroughly.
Scenario 1: Swiggy — Analyse Order Drop-Off
"Given a table of user sessions and a table of completed orders, write a query to find the percentage of sessions that resulted in a completed order, broken down by city."
This tests your ability to JOIN tables, use aggregate functions, and compute derived metrics — all in a single query.
Scenario 2: TCS Client Project — Monthly Active Users
"You have a login_events table with user_id and event_timestamp. Write a query to find the number of monthly active users (MAUs) for each month in 2023."
This tests date functions (MONTH(), YEAR() or DATE_TRUNC depending on the database), COUNT DISTINCT, and GROUP BY.
Scenario 3: Flipkart — Cohort Retention Analysis
"Given an orders table with customer_id and order_date, find the 30-day retention rate for customers who made their first purchase in January 2024."
This is an advanced scenario testing your ability to combine subqueries or CTEs, date arithmetic, and conditional aggregation — the kind of question that separates good candidates from great ones.
Tips to Ace the SQL Interview Round in India
Knowing SQL syntax is necessary but not sufficient. Here are practical tips that will help you stand out in your data analyst technical interview in India.
- Think out loud: Indian interviewers, especially at product companies, want to understand your reasoning process. Narrate your approach before you start writing the query.
- Clarify assumptions: Ask whether the data has duplicates, whether NULLs need special handling, and what the expected output format should look like. This demonstrates professional maturity.
- Know your database: MySQL behaves differently from PostgreSQL in some areas (for example, LIMIT vs TOP). Know which database the company uses and adjust your syntax accordingly.
- Practice on real datasets: Use platforms like HackerRank, LeetCode, and StrataScratch. Many problems on StrataScratch are based on actual interview questions from Indian and global tech companies.
- Optimise after writing: Write a working query first, then discuss how you would optimise it. Do not get bogged down trying to write the perfect query on the first attempt.
- Pair SQL skills with a strong resume: Even the best SQL skills will not get you an interview call if your resume does not highlight them effectively. Make sure your resume clearly lists the SQL tools, databases, and projects you have worked on.
Build your free ATS resume today and make your SQL skills impossible to overlook
Most Common Mistakes Candidates Make in SQL Interviews
Avoiding these pitfalls can be just as important as knowing the right answers.
- Using SELECT * without justification: Always specify the columns you need. Using SELECT * signals lazy habits to an interviewer.
- Ignoring NULLs in JOINs: A JOIN on a column that contains NULLs can produce unexpected results. Always address NULL handling explicitly.
- Confusing RANK and DENSE_RANK: Know the difference and be able to cite a scenario where each is appropriate.
- Not testing edge cases: What happens if the table is empty? What if there are ties? Mentioning edge cases demonstrates senior-level thinking.
- Forgetting to handle date formats: Indian databases often store dates in multiple formats. Always confirm the format and use appropriate conversion functions.
How to Structure Your SQL Practice Plan
If your interview is four weeks away, here is a structured plan to maximise your preparation for SQL interview questions for data analyst roles in India.
- Week 1 — Foundations: Revisit SELECT, WHERE, GROUP BY, HAVING, ORDER BY, and all JOIN types. Solve at least ten problems on HackerRank's SQL track.
- Week 2 — Intermediate Concepts: Focus on subqueries, CTEs, UNION/UNION ALL, and string/date functions. Practice finding duplicates, Nth highest values, and basic aggregations.
- Week 3 — Window Functions: Dedicate the entire week to ROW_NUMBER, RANK, DENSE_RANK, LAG, LEAD, and running totals. These appear in almost every advanced SQL interview question for data analyst candidates.
- Week 4 — Mock Interviews and Optimisation: Do timed mock interviews. Practice explaining your query logic verbally. Review query optimisation techniques and execution plans.
Conclusion
SQL is the backbone of data analyst work in India, and being thoroughly prepared for SQL interview questions is the most direct path to landing offers at companies ranging from TCS and Cognizant to Flipkart and Razorpay. The questions in this guide cover the full spectrum — from the fundamentals that trip up freshers to the advanced window functions and optimisation techniques that senior candidates are expected to master. Beyond just memorising answers, focus on understanding the underlying logic, practising on real datasets, and communicating your thought process clearly during the interview. Pair your SQL expertise with a well-crafted resume that tells a compelling story about your analytical background, and you will be in the strongest possible position to succeed. If you are still working on your resume, build your free ATS resume on PulseStack to ensure your profile makes it past automated screening systems and onto the desks of hiring managers who will genuinely appreciate your SQL skills.
Tags
Resume Builder Team
Career experts helping job seekers build better resumes and land their dream jobs at top companies across India.