Skip to content
Free course Data Analytics Certificate included

Introduction to SQL for Data Analysis

Query databases to answer business questions

  • Beginner level
  • 8 hours
  • 13 lessons
  • English
  • By Muninder Singh

What you'll learn

  • Explain tables, rows, columns, primary keys and foreign keys
  • Set up a free practice database and create tables with sample data
  • Write SELECT queries with WHERE, ORDER BY, DISTINCT and LIMIT
  • Handle missing values correctly with IS NULL and COALESCE
  • Summarise data with COUNT, SUM, AVG, MIN, MAX, GROUP BY and HAVING
  • Combine tables with INNER JOIN and LEFT JOIN
  • Use simple subqueries and save useful queries as views
  • Insert, update and delete rows safely, and understand what indexes do

Course curriculum

4 sections · 13 lessons · 8h 20m

01Databases and SQL 3 lessons
  • What Is a Database? Free preview30 min

    What is a database?

    A database is an organised collection of data that a computer can store, search and update quickly. When you check a train ticket's PNR status, pay with UPI, or look up your marks on a university portal, the website is reading rows from a database.

    Most business databases are relational databases. They store data in tables that are linked to each other. Popular relational database systems include MySQL, PostgreSQL, SQLite, Microsoft SQL Server and Oracle. The language used to talk to all of them is SQL (Structured Query Language, often pronounced "sequel" or "S-Q-L").

    This free introduction to SQL for data analysis teaches you to read data from such databases and turn it into answers.

    Tables, rows and columns

    A table looks like a sheet in Excel:

    • A column (also called a field) holds one kind of information, such as name or city. Every value in a column has the same data type: whole numbers, decimals, text or dates.
    • A row (also called a record) holds all the information about one thing, such as one customer.

    Our sample database: a small shop

    Throughout this course we use a small stationery and electronics shop. It has three tables.

    customers

    customer_idnamecityphonejoined_on
    1Asha VermaJaipur98000000012025-11-10
    2Rohit SharmaLucknowNULL2025-12-02
    3Imran KhanJaipur98000000032025-12-15
    4Neha GuptaIndore98000000042026-01-04
    5Priya NairKochiNULL2026-01-20
    6Vikram SinghLucknow98000000062026-02-11

    products (price in ₹)

    product_idnamecategoryprice
    101NotebookStationery60
    102Pen PackStationery50
    103Pen Drive 32 GBElectronics450
    104Wireless MouseElectronics599
    105Water BottleHome250
    106Desk LampHome899

    orders (one product per order, to keep things simple)

    order_idcustomer_idproduct_idquantityorder_date
    1110152026-01-05
    2110312026-01-12
    3210412026-01-20
    4310242026-02-03
    53101102026-02-03
    6410522026-02-14
    7210322026-03-01
    8510412026-03-08
    9110512026-03-15
    10410222026-03-22

    The phone numbers are made up. NULL means "no value recorded", which we study in Section 2.

    Primary keys and foreign keys

    A primary key is a column whose value is unique for every row and never empty. customer_id is the primary key of customers: there can be only one customer number 3. Names are not good keys, because two customers can share a name.

    A foreign key is a column that points to the primary key of another table. In orders, customer_id points to customers and product_id points to products. Order 5 says "customer 3 bought 10 of product 101", which means Imran Khan bought 10 notebooks.

    Why split data this way instead of one big sheet? If Imran changes his phone number, you update one row in customers, not every order he ever placed. This reduces duplicate data and mistakes.

    Databases versus spreadsheets

    Spreadsheet (Excel, Sheets)Relational database
    Great for small data and quick calculationsHandles millions of rows comfortably
    Anyone can type anything in any cellColumns have fixed data types and rules
    Usually one person edits at a timeMany users and apps read and write together
    Links between sheets are fragileTables are linked by keys
    Steps are done by handA saved query repeats the same analysis instantly

    Analysts use both: SQL to pull and summarise data, Excel or Power BI to present it.

    What SQL can do

    SQL statements fall into a few groups. In this course you will mostly use the first one.

    • Query data: SELECT
    • Change data: INSERT, UPDATE, DELETE
    • Define structure: CREATE TABLE, CREATE VIEW, CREATE INDEX

    Key points

    • A relational database stores data in linked tables of rows and columns.
    • A primary key identifies each row uniquely; a foreign key links to another table.
    • SQL is the standard language for working with relational databases.

    Practice task

    Using only the three tables above, answer these on paper:

    1. Which customer placed order 7, and which product did they buy?
    2. How many orders did Asha Verma place?
    3. Which customer has not placed any order yet?
    4. Which product has never been ordered?

    Keep your answers. In Section 4 you will get the same answers with SQL joins and check that they match.

  • Setting Up a Practice Environment Free preview35 min

    Choose a practice tool

    You learn SQL by typing queries and seeing results. Pick one of these free options. All of them run the queries in this course.

    OptionGood forNotes
    Online SQL playgroundStarting immediately, cyber café, any deviceSearch for "SQLite online" or "SQL playground". Data may be lost when you close the tab, so keep your script saved
    DB Browser for SQLiteLow-cost laptops, offline practiceFree desktop app for Windows, macOS and Linux. The database is a single .db file
    MySQL Community Server + MySQL WorkbenchLearning the database used by many Indian companies and websitesLarger install; you create a username and password during setup

    If you are unsure, start with DB Browser for SQLite. It is small, works offline and has no server to manage. Download it only from its official website, sqlitebrowser.org.

    Creating the shop database in DB Browser for SQLite

    1. Open DB Browser and click New Database. Save the file as shop.db in a folder you can find, such as Documents.
    2. If a "create table" window opens, close it. We will create tables with SQL instead.
    3. Open the Execute SQL tab. This is where you type queries.
    4. Paste the full script below and click the Execute button (the play icon), or press Ctrl + Enter.
    5. Click Write Changes (or press Ctrl + S) so the data is saved to the file.

    In MySQL Workbench, first run CREATE DATABASE shop; and USE shop;, then run the same script.

    The setup script

    CREATE TABLE customers (
      customer_id INT PRIMARY KEY,
      name        VARCHAR(50) NOT NULL,
      city        VARCHAR(30),
      phone       VARCHAR(15),
      joined_on   DATE
    );
    
    CREATE TABLE products (
      product_id INT PRIMARY KEY,
      name       VARCHAR(50) NOT NULL,
      category   VARCHAR(30),
      price      INT
    );
    
    CREATE TABLE orders (
      order_id    INT PRIMARY KEY,
      customer_id INT,
      product_id  INT,
      quantity    INT,
      order_date  DATE,
      FOREIGN KEY (customer_id) REFERENCES customers(customer_id),
      FOREIGN KEY (product_id) REFERENCES products(product_id)
    );
    
    INSERT INTO customers VALUES
    (1, 'Asha Verma',   'Jaipur',  '9800000001', '2025-11-10'),
    (2, 'Rohit Sharma', 'Lucknow', NULL,         '2025-12-02'),
    (3, 'Imran Khan',   'Jaipur',  '9800000003', '2025-12-15'),
    (4, 'Neha Gupta',   'Indore',  '9800000004', '2026-01-04'),
    (5, 'Priya Nair',   'Kochi',   NULL,         '2026-01-20'),
    (6, 'Vikram Singh', 'Lucknow', '9800000006', '2026-02-11');
    
    INSERT INTO products VALUES
    (101, 'Notebook',        'Stationery',  60),
    (102, 'Pen Pack',        'Stationery',  50),
    (103, 'Pen Drive 32 GB', 'Electronics', 450),
    (104, 'Wireless Mouse',  'Electronics', 599),
    (105, 'Water Bottle',    'Home',        250),
    (106, 'Desk Lamp',       'Home',        899);
    
    INSERT INTO orders VALUES
    (1,  1, 101, 5,  '2026-01-05'),
    (2,  1, 103, 1,  '2026-01-12'),
    (3,  2, 104, 1,  '2026-01-20'),
    (4,  3, 102, 4,  '2026-02-03'),
    (5,  3, 101, 10, '2026-02-03'),
    (6,  4, 105, 2,  '2026-02-14'),
    (7,  2, 103, 2,  '2026-03-01'),
    (8,  5, 104, 1,  '2026-03-08'),
    (9,  1, 105, 1,  '2026-03-15'),
    (10, 4, 102, 2,  '2026-03-22');

    Understanding the script

    • CREATE TABLE defines a table, its columns and each column's data type.
    • INT stores whole numbers. VARCHAR(50) stores text up to 50 characters. DATE stores a date written as 'YYYY-MM-DD'.
    • PRIMARY KEY makes the column unique for every row.
    • NOT NULL means the value cannot be left empty: every customer must have a name.
    • FOREIGN KEY ... REFERENCES records the link from orders to the other two tables.
    • INSERT INTO ... VALUES adds rows. Text and dates go inside single quotes; numbers do not.
    • Each statement ends with a semicolon ;.

    Prices are stored as whole rupees with INT to keep the results identical in every database. Real systems often use DECIMAL(10,2) for money so that paise are stored exactly.

    Check that it worked

    Run this query:

    SELECT COUNT(*) FROM orders;

    You should see 10. Try the same with customers (6) and products (6). If you get an error such as "table already exists", you ran the script twice. That is harmless for practice: create a fresh database file and run it once.

    SQL writing habits

    • SQL keywords are not case-sensitive. select works like SELECT, but writing keywords in capitals makes queries easier to read.
    • Spaces and line breaks do not matter. Put each clause on its own line.
    • A line starting with -- is a comment that SQL ignores. Use comments to note what a query does.
    • Save your queries in a text file (for example practice.sql) so you can reuse them.

    Common mistakes

    • Using double quotes or curly "smart" quotes copied from a word processor around text. Use plain single quotes: 'Jaipur'.
    • Forgetting the comma between columns or between rows of VALUES.
    • Closing DB Browser without clicking Write Changes, which loses your new data.

    Practice task

    1. Create shop.db and run the setup script.
    2. Confirm the row counts: 6 customers, 6 products, 10 orders.
    3. Add a comment line at the top of your script, such as -- Shop practice database, and save the script as shop_setup.sql.
    4. Open the Browse Data tab (or run SELECT * FROM products;) and check that the prices match the tables in Lesson 1.
  • Your First SELECT Query 35 min
02Filtering and Sorting 3 lessons
  • WHERE and Comparison Operators 40 min
  • Combining Conditions and NULLs 35 min
  • Sorting, DISTINCT and Top Results 35 min
03Summarising Data 3 lessons
  • Aggregate Functions 40 min
  • GROUP BY and HAVING 45 min
  • Working with Dates 40 min
04Joins, Subqueries and Changing Data 4 lessons
  • INNER JOIN and LEFT JOIN 50 min
  • Subqueries, Views and Indexes 45 min
  • Changing Data Safely and Final Project 50 min
  • Final Exam 20 min

About this course

Why learn SQL?

Most business data does not live in Excel files. It lives in databases: billing software, school management systems, online shops, banks and government portals all store their records in tables. SQL (Structured Query Language) is the standard language for asking those databases questions, such as "Which city brought in the most revenue last month?"

SQL is one of the most requested skills for data analyst, MIS executive, business analyst and back-office roles, and it is also useful for developers and IT support staff.

How you will learn

The whole course uses one small, realistic database: a shop with customers, products and orders. You will create it yourself in a few minutes, then run every example and see exactly the same results shown in the lessons.

You can practise on a free tool: SQLite (with DB Browser for SQLite), MySQL, or an online SQL playground in your browser. The queries use standard SQL that works in both MySQL and SQLite, and the lessons point out the few places where they differ.

What you will be able to do

By the end you will answer real business questions with SQL: revenue by city and category, best customers, monthly trends, products that never sold and customers who never ordered, and you will know how to change data safely without damaging it.

Requirements

  • Basic computer skills; some Excel experience helps but is not required
  • A computer with free database software (SQLite or MySQL), or any browser for an online SQL playground
  • No programming experience needed

Earn a verifiable certificate

Pass the final online exam (20 minutes, 15 questions, pass mark 40%) to receive your certificate instantly. Each certificate has a unique number and QR code for instant verification.

This is an independent, institute-issued skill-training certificate — not a government-recognised degree or diploma.

Your educator

M

Muninder Singh

Frequently asked questions

Do I need to know programming before learning SQL?
No. SQL is a query language, not a full programming language, and this course starts from zero. If you can write an Excel formula, you can learn SQL.
Will the queries work in MySQL, SQLite and other databases?
The course uses standard SQL that runs in both MySQL and SQLite. Most of it also works in PostgreSQL and SQL Server; the lessons note the few differences, such as date functions and LIMIT.
Can I practise SQL without installing anything?
Yes. You can use a free online SQL playground in your browser. Installing SQLite with DB Browser for SQLite is also quick and works on low-cost laptops.
Is SQL useful if I already know Excel?
Very. Excel is great for small files, but SQL handles large data, combines many tables and lets you repeat the same analysis instantly. Analysts usually use both.
Is the certificate free?
Yes. Pass the final exam with 40% or more to download a free GCI EDU skill certificate. It is an institute-issued training certificate, not a government-recognised degree.

Have a question about this course?

Leave your details and our team will get back to you, usually within one working day.

Share a phone number or an email so we can reach you. We never share your details.

Related articles

Tutorials 8 min read

SQL Queries for Beginners: SELECT, WHERE, GROUP BY and JOIN

Learn the SQL queries used in everyday data work with two small tables you can type in five minutes: SELECT, WHERE, ORDER BY, COUNT and AVG, GROUP BY, HAVING, INNER JOIN and LEFT JOIN, with real outputs.

Read article →

You may also like

Data Analytics

Data Analysis with Excel

Turn raw data into clear answers with formulas, pivot tables and charts

9 hrs 13 lessons Beginner Certificate

Free

Includes certificate

Enrol free