← Blog
BEGINNER TUTORIAL — INDIA 2026

SQL Tutorial for Beginners India 2026
Learn SQL from Scratch for Data Analyst Jobs

This tutorial teaches you SQL from zero — no prior experience needed. Every concept is explained with Indian business examples (orders, customers, products, sales data) and runnable code. By the end you will be able to write the queries that clear Indian data analyst interview rounds.

Ch 1: What is SQL and Why Every Data Analyst in India Needs ItCh 2: Your First SQL QueryCh 3: Filtering RowsCh 4: Sorting ResultsCh 5: Counting and SummarisingCh 6: Combining TablesCh 7: Subqueries and CTEsCh 8: Window Functions
SQL Interview Q&A →Live SQL Training →
What you will learn in this tutorial
SELECT & FROMBeginner
WHERE & filteringBeginner
ORDER BY & LIMITBeginner
GROUP BY & aggregatesIntermediate
INNER JOIN & LEFT JOINIntermediate
Subqueries & CTEsIntermediate
Window functionsAdvanced
Interview patternsAdvanced
1

What is SQL and Why Every Data Analyst in India Needs It

SQL (Structured Query Language) is the language you use to talk to databases. Every company that collects data stores it in a relational database — sales transactions, customer records, inventory, HR data, financial records. SQL is the universal tool to retrieve, filter, and summarise that data.

In India's data analyst job market in 2026, SQL is tested in nearly every technical interview round. Companies use it to filter candidates who can do the job from those who cannot. A candidate who writes correct SQL JOINs and GROUP BY queries in an interview gets offers. Those who cannot, do not — regardless of their other qualifications.

You do not need programming experience to learn SQL. You do not need mathematics beyond basic addition and percentages. If you can write an Excel formula, you can learn SQL.

2

Your First SQL Query — SELECT and FROM

Every SQL query starts with SELECT (what columns you want) and FROM (which table to get them from). Think of a table like an Excel sheet — it has rows (records) and columns (fields).

The * (asterisk) means "all columns." You will almost never use SELECT * in real work — always specify only the columns you need.

-- Retrieve all columns from the customers table
SELECT * FROM customers;

-- Retrieve specific columns only
SELECT customer_id, name, city, phone
FROM customers;

-- Give a column a readable alias (rename in output)
SELECT customer_id AS "Customer ID",
       name        AS "Customer Name",
       city        AS "City"
FROM customers;
3

Filtering Rows — WHERE Clause

WHERE filters which rows to return. Only rows where the condition is TRUE are included. You can combine conditions with AND (both must be true) and OR (either can be true).

Common operators: = (equals), != or <> (not equals), > < >= <= (comparisons), BETWEEN (inclusive range), IN (list of values), LIKE (pattern matching with % wildcard), IS NULL / IS NOT NULL.

-- Customers from Delhi only
SELECT name, city FROM customers
WHERE city = 'Delhi';

-- Orders above ₹50,000 placed in 2025
SELECT order_id, customer_id, amount, order_date
FROM orders
WHERE amount > 50000
  AND YEAR(order_date) = 2025;

-- Customers from Delhi OR Mumbai
SELECT name, city FROM customers
WHERE city IN ('Delhi', 'Mumbai', 'Noida');

-- Products with names starting with "Pro"
SELECT product_name, price FROM products
WHERE product_name LIKE 'Pro%';

-- Orders with no delivery date recorded yet
SELECT order_id FROM orders
WHERE delivery_date IS NULL;
4

Sorting Results — ORDER BY

ORDER BY sorts the output. ASC (ascending, A→Z, smallest→largest) is the default. DESC (descending) reverses it. You can sort by multiple columns — the second column breaks ties in the first.

-- Most expensive products first
SELECT product_name, price
FROM products
ORDER BY price DESC;

-- Customers alphabetically by city, then by name within each city
SELECT name, city FROM customers
ORDER BY city ASC, name ASC;

-- Top 5 largest orders
SELECT order_id, customer_id, amount
FROM orders
ORDER BY amount DESC
LIMIT 5;   -- use TOP 5 in SQL Server
5

Counting and Summarising — GROUP BY and Aggregate Functions

Aggregate functions collapse many rows into a single value: COUNT(), SUM(), AVG(), MIN(), MAX(). GROUP BY splits the data into groups before aggregating — one row per group in the output.

HAVING filters groups after aggregation (the equivalent of WHERE for grouped results). You cannot use WHERE with aggregate functions — use HAVING instead.

-- Total sales per city
SELECT city,
       SUM(amount) AS total_sales,
       COUNT(*)    AS order_count,
       AVG(amount) AS avg_order_value
FROM orders o
JOIN customers c ON o.customer_id = c.customer_id
GROUP BY city
ORDER BY total_sales DESC;

-- Cities with total sales above ₹10,00,000
SELECT city, SUM(amount) AS total_sales
FROM orders o
JOIN customers c ON o.customer_id = c.customer_id
GROUP BY city
HAVING SUM(amount) > 1000000;

-- Products sold fewer than 5 times (slow movers)
SELECT product_id, COUNT(*) AS times_sold
FROM order_items
GROUP BY product_id
HAVING COUNT(*) < 5;
6

Combining Tables — JOINs

Real databases split data across multiple tables. JOINs combine them. The most important JOINs for data analysts:

INNER JOIN — returns rows with a match in BOTH tables. Use when both sides must exist. LEFT JOIN — returns ALL rows from the left table + matched rows from the right. Right side columns are NULL where there is no match. Use when you want to include records even if there is no related record on the right.

The classic LEFT JOIN trick: filter WHERE right_table.column IS NULL to find records that have NO match — e.g., customers who have never placed an order.

-- INNER JOIN: orders with customer names (only orders with known customers)
SELECT o.order_id, c.name, c.city, o.amount
FROM orders o
INNER JOIN customers c ON o.customer_id = c.customer_id;

-- LEFT JOIN: all customers, including those with no orders
SELECT c.name, c.city, o.order_id, o.amount
FROM customers c
LEFT JOIN orders o ON c.customer_id = o.customer_id;

-- Customers who have NEVER placed an order
SELECT c.customer_id, c.name
FROM customers c
LEFT JOIN orders o ON c.customer_id = o.customer_id
WHERE o.order_id IS NULL;

-- Three-table JOIN: order + customer + product
SELECT o.order_id, c.name, p.product_name, oi.quantity, oi.unit_price
FROM orders o
JOIN customers   c  ON o.customer_id  = c.customer_id
JOIN order_items oi ON o.order_id     = oi.order_id
JOIN products    p  ON oi.product_id  = p.product_id;
7

Subqueries and CTEs — Multi-Step Queries

A subquery is a query nested inside another query — useful for two-step problems like "find customers who spent above average" or "find the second highest salary." A CTE (WITH clause) names the subquery so you can reference it clearly — always prefer CTEs over deeply nested subqueries for readability.

-- Find orders above the average order value
SELECT order_id, customer_id, amount
FROM orders
WHERE amount > (SELECT AVG(amount) FROM orders);

-- Find the second highest salary (classic interview question)
SELECT MAX(salary) AS second_highest
FROM employees
WHERE salary < (SELECT MAX(salary) FROM employees);

-- CTE version (cleaner for complex queries)
WITH avg_sales AS (
  SELECT city, AVG(amount) AS city_avg
  FROM orders o
  JOIN customers c ON o.customer_id = c.customer_id
  GROUP BY city
)
SELECT city, city_avg
FROM avg_sales
WHERE city_avg > (SELECT AVG(amount) FROM orders)
ORDER BY city_avg DESC;
8

Window Functions — The Advanced Skill That Gets You Hired

Window functions perform calculations across a set of rows related to the current row — without collapsing the result into one row like GROUP BY does. They are the most commonly tested advanced SQL topic in Indian data analyst interviews at mid-level and above.

PARTITION BY splits the data into windows (like GROUP BY but without collapsing rows). ORDER BY within the window function defines the order for ranking or running calculations. ROW_NUMBER() assigns a unique number to each row. RANK() / DENSE_RANK() assigns ranks with tie-handling. LAG() / LEAD() access the previous or next row's value. SUM() / AVG() OVER() create running totals or rolling averages.

-- Rank employees by salary (highest = 1) within each department
SELECT name, department, salary,
  RANK() OVER (
    PARTITION BY department
    ORDER BY salary DESC
  ) AS salary_rank
FROM employees;

-- Running total of daily sales
SELECT sale_date, amount,
  SUM(amount) OVER (
    ORDER BY sale_date
    ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
  ) AS cumulative_sales
FROM daily_sales;

-- Month-over-month sales change using LAG
SELECT month, revenue,
  LAG(revenue) OVER (ORDER BY month) AS prev_month,
  revenue - LAG(revenue) OVER (ORDER BY month) AS change
FROM monthly_revenue;

-- Top 2 products per category (top-N-per-group — asked in interviews)
SELECT category, product_name, total_sales
FROM (
  SELECT category, product_name,
         SUM(amount) AS total_sales,
         ROW_NUMBER() OVER (
           PARTITION BY category
           ORDER BY SUM(amount) DESC
         ) AS rn
  FROM sales s
  JOIN products p ON s.product_id = p.product_id
  GROUP BY category, product_name
) ranked
WHERE rn <= 2;

How to Practise SQL Effectively

1
Install MySQL or use DB Fiddle online
DB Fiddle (dbfiddle.uk) lets you run SQL in your browser instantly — no installation. MySQL Workbench or DBeaver are free desktop tools for local practice.
2
Create a practice database with Indian business data
Build tables for customers (name, city, phone), orders (order_id, amount, date), products (name, category, price). Populate with 50–100 rows. This makes every query feel real.
3
Write queries from scratch — do not just read them
Reading SQL and writing SQL are different skills. Type every query yourself. Make mistakes. Debug them. That process builds the muscle memory for interviews.
4
Practice the 5 most-asked patterns daily
LEFT JOIN + IS NULL, GROUP BY + HAVING, second highest value, top-N per group, running total. Drill these until you can write them in under 2 minutes each.
5
Time yourself on interview problems
Indian SQL rounds give you 30–45 minutes for 3–4 questions. Set a timer. If you cannot solve in 10 minutes per question, you need more practice on that pattern.
Continue learning
SQL Interview Q&A (30 questions)SQL JOINs ExplainedFull Skills ChecklistBest Analytics Tools India

Frequently Asked Questions

How long does it take to learn SQL for a data analyst job in India?

With daily practice of 1–2 hours, most beginners can learn SQL well enough to clear a data analyst technical interview in 6–10 weeks. The basics — SELECT, WHERE, GROUP BY, and JOINs — take 2–3 weeks. Window functions and subqueries take another 3–4 weeks of consistent practice. What matters more than speed is depth — companies test whether you can write correct SQL under pressure, not just whether you know the syntax.

Which SQL database should a beginner learn first in India?

Start with MySQL or PostgreSQL — both are free, widely used, and teach the same core SQL syntax that transfers to SQL Server, Oracle, and BigQuery. MySQL is installed by millions of developers and has excellent beginner resources. PostgreSQL is increasingly preferred for its advanced features. Most Indian data analyst interviews test generic SQL that works across all databases — JOINs, GROUP BY, and window functions are the same in all major dialects.

Is SQL enough to get a data analyst job in India?

Strong SQL is the #1 skill for clearing technical interview rounds in India, but you also need Excel (for data manipulation and business reporting) and Power BI or Tableau (for visualisation). SQL + Excel + Power BI is the minimum toolkit for most data analyst roles in India in 2026. Python is increasingly asked for at mid-to-senior levels. SQL is the non-negotiable foundation — without it, you will not pass the technical round even if your other skills are strong.

What are the most important SQL concepts for data analyst interviews in India?

Indian data analyst interviews most commonly test: (1) JOINs — especially LEFT JOIN with IS NULL to find non-matching records; (2) GROUP BY with HAVING — aggregate queries with filtered groups; (3) Subqueries — particularly for "second highest salary" and "top N per group" problems; (4) Window functions — ROW_NUMBER(), RANK(), LAG() — tested at mid-level and above; (5) NULL handling — knowing that NULL = NULL is NULL and using IS NULL correctly. Practise these five areas and you will clear most Indian SQL interview rounds.

EVIKA ACADEMY · NOIDA SECTOR 51 · LIVE SQL TRAINING

Learn SQL with live instruction and real datasets

Doubt clearing in real time. Mock SQL interview rounds. Portfolio projects. Free demo class first.

Book Free Demo →