SQL is tested in nearly every data-related role in India: data engineers, data analysts, backend engineers, data scientists, and business intelligence professionals. This guide covers the SQL questions asked at Indian product companies, service IT firms, and analytics companies: from basic joins to window functions and query optimisation.
SQL Fundamentals
JOIN types tested at every level: INNER JOIN (only matching rows in both tables), LEFT JOIN (all from left, matching from right, NULL if no match), RIGHT JOIN (all from right), FULL OUTER JOIN (all rows from both). Self join: a table joined with itself (used for hierarchical data: manager-employee relationships). Subqueries vs JOINs: subqueries in WHERE (correlated vs non-correlated), in FROM (derived tables), in SELECT (scalar subqueries). GROUP BY and HAVING: GROUP BY aggregates rows; HAVING filters aggregated results (WHERE filters before aggregation, HAVING filters after). DISTINCT vs GROUP BY: use GROUP BY when you also need an aggregate, DISTINCT for unique values only.
Window Functions
Window functions are the most commonly tested advanced SQL topic at Indian product and analytics companies. ROWNUMBER(): unique sequential number per partition (removes duplicates: keep row with ROWNUMBER = 1). RANK(): same rank for ties, skips numbers (1, 1, 3). DENSE_RANK(): same rank for ties, no skips (1, 1, 2). LAG(col, n): value from n rows previous in the partition: used for comparing current vs previous period. LEAD(col, n): value from n rows ahead. SUM OVER (PARTITION BY...): running totals and cumulative sums. Most common interview questions using window functions: find the second highest salary per department, find users who made purchases in 3 consecutive months, rank products by sales within each category.
Tricky SQL Scenarios
Scenario questions that distinguish intermediate from advanced SQL: (1) Find users who logged in every day for the past 30 days. Solution: count distinct dates, filter where count = 30, use date arithmetic. (2) Find the most recent order per customer. Solution: ROWNUMBER() OVER (PARTITION BY customerid ORDER BY orderdate DESC) = 1 in a subquery. (3) Calculate month-over-month revenue growth. Solution: LAG(revenue, 1) OVER (ORDER BY month) to get previous month, then (current - previous) / previous. (4) Find duplicate records and keep only one. Solution: ROWNUMBER() OVER (PARTITION BY uniquecolumns) and delete rows where rownumber > 1. (5) Pivot data from rows to columns. Solution: CASE WHEN with GROUP BY, or database-specific PIVOT syntax.
Query Optimisation
Query optimisation is tested at senior data engineering and senior backend roles. Key concepts: EXPLAIN/EXPLAIN ANALYZE: show the query execution plan: identify full table scans, index usage, join types. Index types: B-tree (default: equality and range queries), Hash (equality only), GIN (arrays, JSON, full text), BRIN (large sequential data like timestamps). When NOT to index: high-write tables (indexes slow writes), low-cardinality columns (gender, boolean: index not helpful). Common optimisation techniques: avoid SELECT *, use covering indexes, avoid functions on indexed columns in WHERE (prevents index use), partition large tables, materialise views for complex repeated queries. N+1 query problem: executing one query to get N records then N queries for related data: use JOINs or batch loading instead.
SQL interviews reward practice. Work through 50 SQL problems, then practise explaining your approach with HireStepX's AI mock interviewer.
Practice freeSQL Roles and Salaries in Indian Data Teams
SQL proficiency underpins multiple high-paying roles in India's data economy. Business analysts and data analysts with strong SQL skills earn 6 to 14 LPA at early-stage companies and 18 to 28 LPA at Flipkart, Amazon, or Juspay. Data engineers who combine SQL with dbt, BigQuery, or Redshift command 20 to 40 LPA at growth-stage startups. Analytics engineers at fintechs like Zerodha, Groww, or INDmoney earn 25 to 45 LPA given the volume and complexity of financial transaction data they model. SQL is also tested in every data science and ML engineer interview in India, making it the single most universally assessed technical skill across non-pure-software data roles in the country.
How Indian Companies Test SQL in Interviews
Flipkart's data engineering interviews use their own internal dataset schema resembling product and order tables and ask candidates to write multi-join queries identifying anomalies in delivery SLA compliance. Amazon India analytics interviews follow the STAR structure for SQL as well, asking candidates to first clarify the business question before writing the query. Swiggy and Zomato commonly ask for cohort retention analysis queries, which require self-joins or window functions with ROWS BETWEEN syntax. Paytm tests candidates on writing SQL to detect duplicate UPI transactions within a five-second window using LAG and PARTITION BY. PhonePe's data team asks for query optimisation explanations, requiring candidates to reason about index usage and join order.
PostgreSQL and BigQuery Specifics Tested in India
Indian product companies predominantly use PostgreSQL for transactional systems and Google BigQuery or Amazon Redshift for analytical workloads. Interviewers at these firms increasingly test platform-specific SQL features. For PostgreSQL, candidates should know JSONB query operators, LATERAL joins, and how to use EXPLAIN ANALYZE to interpret sequential scans versus index scans. For BigQuery, interviewers ask about ARRAY_AGG, UNNEST patterns for nested records, and partitioned versus clustered table strategies for cost control. Juspay and Razorpay engineers have noted that candidates who demonstrate awareness of query costs, such as avoiding SELECT star on large BigQuery tables or using materialized views to reduce repeated scan overhead, consistently outperform peers in technical evaluations.
Frequently asked questions
Explore more