Why SQL is the highest-ROI skill for Indian engineers and analysts
SQL is the most underrated career skill in India. Indian learners spend months on React, Python, or ML — but the people landing analyst roles at Flipkart, Swiggy, Razorpay, and Cred? They cleared SQL rounds. The people getting promoted to senior backend engineer? They write SQL that doesn't bring down production.
Roles in India where SQL is mandatory:
- Data Analyst at any product company (₹6-15 LPA freshers, ₹15-35 LPA mid-level)
- Business Analyst / Product Analyst (₹6-25 LPA range)
- Backend Engineer anywhere with a database (so, everywhere)
- Data Engineer (₹10-30 LPA freshers, ₹30-80 LPA senior)
- Data Scientist (every Indian DS role tests SQL in interviews)
- ML Engineer (you'll write a LOT of SQL to prep training data)
- Finance / Operations Analyst at startups (Razorpay, Cred, ZestMoney — yes, these are SQL-heavy)
The unique thing about SQL: it's 40+ years old, but still the dominant language for working with data. Postgres, MySQL, BigQuery, Snowflake, Redshift, ClickHouse — all use SQL with minor dialect variations. Learn it once, use it for your entire career.
Why most Indian engineers are bad at SQL:
- College courses cover SELECT/WHERE/JOIN but skip window functions, CTEs, and query plans
- Most online courses are basic — they don't teach the SQL needed for real interview rounds
- Engineers write CRUD queries via ORM (Prisma, SQLAlchemy) and never actually understand SQL
The opportunity: if you become genuinely good at SQL (not just basics), you stand out instantly in Indian interviews. Top analyst hiring at Flipkart, Amazon India, Microsoft IDC, Google India runs 2-3 SQL rounds. Most candidates fail. Mastering SQL is a relatively short (3-4 months) investment with disproportionate return.
12-week SQL learning roadmap (free, project-based)
Weeks 1-2 — SELECT, WHERE, ORDER BY, LIMIT, basic functions
- Install PostgreSQL locally (recommended) or use DB Fiddle online
- Master: SELECT, FROM, WHERE, ORDER BY, LIMIT, DISTINCT
- String functions: LOWER, UPPER, CONCAT, SUBSTRING, LENGTH, TRIM
- Number functions: ROUND, FLOOR, CEIL, MOD
- Date functions: DATE_TRUNC, EXTRACT, INTERVAL, NOW()
- Solve 50 beginner problems on SQLZoo
Weeks 3-4 — JOINs (the heart of SQL)
- INNER JOIN, LEFT JOIN, RIGHT JOIN, FULL OUTER JOIN
- Self-joins (table joined with itself — common interview question)
- CROSS JOIN and when it's actually useful
- Multi-table joins (3+ tables in one query)
- ON vs USING (vs WHERE for join conditions)
- Practice on a real-ish schema (orders, customers, products, line_items)
Weeks 5-6 — Aggregations and GROUP BY
- COUNT, SUM, AVG, MIN, MAX
- GROUP BY with multiple columns
- HAVING clause (filtering on aggregates)
- COUNT(*) vs COUNT(column) vs COUNT(DISTINCT column)
- FILTER (WHERE ...) clause for conditional aggregations
- Real interview pattern: "Top 5 customers by revenue per month"
Free resources for weeks 1-6:
- SQLZoo — interactive SQL with hints
- Mode SQL Tutorial — excellent free analyst-focused tutorial
- Khan Academy SQL Course — free, structured
- Apna College SQL Tutorial in Hindi
Weeks 7-8 — Subqueries and CTEs (Common Table Expressions)
- Scalar subqueries vs correlated subqueries
- IN, EXISTS, ANY, ALL keyword patterns
- WITH clause (CTE) — readability transformation
- Recursive CTEs (for hierarchical data: org charts, category trees)
- When to use CTE vs subquery vs temp table
Weeks 9-10 — Window functions (the senior SQL skill)
- ROW_NUMBER, RANK, DENSE_RANK
- LAG, LEAD (compare row to previous/next)
- SUM/AVG/COUNT with OVER clause
- PARTITION BY (group within window)
- Running totals, moving averages, percentile calculations
- This is where most Indian engineers fall short in interviews
Weeks 11 — Query optimization basics
- EXPLAIN and EXPLAIN ANALYZE
- Indexes: B-tree, hash, partial, covering
- When indexes help vs hurt
- Statistics and the query planner
- Common anti-patterns: SELECT *, N+1 queries, OR conditions that prevent index use
Week 12 — Real project + interview prep
- Build a portfolio project: take a real dataset (Kaggle, data.gov.in, or your own scraped data), load into Postgres, answer 10 business questions with SQL
- Solve 50 hard SQL problems on LeetCode SQL track or StrataScratch (free tier)
- Practice live SQL on whiteboard / Google Doc (this is how interviews happen)
By end of 12 weeks you'll be ready for fresher analyst / backend interview SQL rounds.
SQL questions Indian companies actually ask in interviews
Based on candidate reports from Flipkart, Amazon India, Swiggy, Cred, Razorpay, Microsoft IDC analyst interviews:
Pattern 1 — Find Nth highest (very common, asked at every product company): "Find the second-highest salary in the employees table." "Find the Nth highest order value per customer." Solution: ROW_NUMBER() or DENSE_RANK() window function + WHERE filter.
Pattern 2 — Cumulative / running aggregation: "For each day, show daily revenue and 7-day moving average revenue." "Show cumulative count of new users by month." Solution: SUM(...) OVER (ORDER BY date ROWS BETWEEN 6 PRECEDING AND CURRENT ROW).
Pattern 3 — Self-join for hierarchical / sequential data: "For each user, find the time between their first and second purchase." "Find pairs of products often bought together." Solution: self-join with WHERE conditions, or LAG window function.
Pattern 4 — Cohort retention: "For users signed up in Jan 2026, what % returned in Feb? Mar?" This is the canonical analyst interview question. Solution: combination of subquery (get cohort), date functions, and aggregation.
Pattern 5 — Top N per group: "Find the top 3 selling products in each category." Solution: ROW_NUMBER() OVER (PARTITION BY category ORDER BY sales DESC), then filter WHERE rn <= 3.
Pattern 6 — Gaps and islands: "Find continuous date ranges where a user was active." "Find the longest streak of consecutive logins per user." Advanced pattern, asked at senior data engineer rounds.
Pattern 7 — Pivoting / unpivoting: "Show monthly sales as columns (Jan, Feb, Mar...) instead of rows." Solution: conditional aggregation with CASE WHEN, or PIVOT in some dialects.
If you can solve all 7 patterns smoothly on a whiteboard, you'll clear 90%+ of Indian SQL interview rounds.
SQL performance — what every Indian backend engineer must know
Fresher engineers write SQL that "works." Senior engineers write SQL that "works at scale." Here's the gap-closer for performance:
Indexes — when they help and when they hurt:
- INDEX on columns you filter by (WHERE), join on (JOIN ... ON), or sort by (ORDER BY)
- INDEX on user_id where you query "WHERE user_id = ?" — yes
- INDEX on gender (low cardinality, 2 values) — usually NO, the planner ignores it
- INDEX on email — yes (high cardinality, often filtered)
- Composite indexes: order matters! INDEX(country, city) helps WHERE country = ? AND city = ?, but NOT just WHERE city = ?
Common Indian backend mistakes:
- SELECT * in production — fetches columns you don't need, hurts cache efficiency
- N+1 queries from ORMs (Prisma, SQLAlchemy) — fetching parent, then a query per child
- OR conditions that prevent index use — sometimes UNION is faster
- Using functions on indexed columns: WHERE LOWER(email) = ? — index can't be used unless you have a functional index
- Not using LIMIT — fetching 1M rows when you wanted 10
- Loading entire result sets into application memory instead of streaming
EXPLAIN ANALYZE is your best friend: For Postgres / MySQL, prefix any query with EXPLAIN ANALYZE to see the actual execution plan. Learn to read it:
- "Seq Scan" on a large table = bad (no index used)
- "Index Scan" = good
- "Bitmap Index Scan" = good (for multiple matches)
- Estimated rows vs actual rows — if they're off by 10x+, your statistics are stale (ANALYZE the table)
Indian product company senior interview question: "Here's a slow query. The table has 50M rows. How would you make it faster?" Expected answer: read EXPLAIN, identify scan type, suggest indexes, rewrite if needed, denormalize if necessary, add caching, partition the table.
If you can answer this confidently, you're already ahead of 80% of Indian backend engineers.
Advanced SQL — Window functions, CTEs, and the senior gap
Most Indian engineers stop at JOINs and GROUP BY. The 20% who learn window functions and recursive CTEs land senior roles 1-2 years faster.
Window functions — the cheat sheet:
ROW_NUMBER() — unique row number per partition (no ties) RANK() — ranking with ties leaving gaps (1, 2, 2, 4) DENSE_RANK() — ranking with ties without gaps (1, 2, 2, 3) NTILE(n) — divide rows into n buckets LAG(col, n) — value n rows before current (default n=1) LEAD(col, n) — value n rows after current FIRST_VALUE, LAST_VALUE — first/last in window SUM/AVG/COUNT/MIN/MAX with OVER — running aggregations
Window function clauses to master:
- PARTITION BY (group by within window)
- ORDER BY (within partition)
- ROWS / RANGE BETWEEN (frame specification)
Recursive CTE — for hierarchical data: WITH RECURSIVE org_chart AS ( SELECT id, name, manager_id, 1 AS level FROM employees WHERE manager_id IS NULL UNION ALL SELECT e.id, e.name, e.manager_id, oc.level + 1 FROM employees e JOIN org_chart oc ON e.manager_id = oc.id ) SELECT * FROM org_chart;
This walks the entire org tree. Useful for: category trees, comment threads, file systems, dependency graphs.
JSON in SQL (Postgres / MySQL 8+):
- Postgres has rich JSON support: jsonb_set, jsonb_extract_path, ->, ->>, @> operators
- MySQL 8+ has JSON_EXTRACT, JSON_OBJECT
- Many Indian product companies use JSON columns for flexible schemas — learn this for senior roles
Free advanced SQL resources:
- Use the Index, Luke — best free book on database performance
- Modern SQL website — covers post-SQL-92 features
- PostgreSQL Tutorial — comprehensive free Postgres reference
If you master these, you'll clear senior data engineer / staff backend engineer SQL rounds at top Indian product companies.
Frequently asked questions
Which SQL database should I learn — MySQL or PostgreSQL?▾
PostgreSQL — more powerful, more features (window functions, JSON, CTEs all work better), and increasingly the default at Indian product startups. MySQL is still common at legacy enterprises and PHP shops. Learn PostgreSQL first; switching to MySQL later takes a weekend.
Do I need to learn SQL if I use an ORM like Prisma?▾
Yes, absolutely. ORMs generate SQL behind the scenes — without understanding SQL, you'll write code that produces N+1 queries, missing indexes, and full table scans. Every senior backend engineer in India can read and write raw SQL, even if they primarily use an ORM.
Can I get a data analyst job with just SQL and Excel?▾
Yes, for entry-level analyst roles at Indian product companies. Many Flipkart, Swiggy, Zomato analyst roles primarily need SQL + Excel + basic visualization. Add Python (pandas) and a BI tool (Tableau, Power BI, Metabase) to qualify for mid-level analyst roles paying ₹12-25 LPA.
How long does it take to be SQL-job-ready?▾
3-4 months of consistent practice (1 hour/day) to clear fresher analyst SQL rounds at Indian product companies. Add 2-3 more months of advanced SQL (window functions, CTEs, optimization) to qualify for senior backend or mid-level analyst roles.
What's the best free SQL course in 2026?▾
Mode SQL Tutorial (mode.com/sql-tutorial) is the best free analyst-focused course. SQLZoo (sqlzoo.net) is best for interactive practice. PostgreSQL Tutorial (postgresqltutorial.com) is best for Postgres-specific depth. Combine all three over 12 weeks.
Is NoSQL going to replace SQL?▾
No. NoSQL has its place (caching with Redis, document DBs for flexible schemas), but every serious product company in India runs PostgreSQL or MySQL as the primary database. SQL is more relevant in 2026 than it was 10 years ago — the rise of analytics platforms (Snowflake, BigQuery, ClickHouse) cemented SQL's dominance.
Should I learn SQL for backend engineering or for analyst roles?▾
Both paths need SQL. Differences: analysts need stronger window functions, complex aggregations, cohort analysis. Backend engineers need stronger query optimization, indexing strategy, transactions, and schema design. The first 80% of SQL is the same — diverge after that based on your career target.