SQL Fundamentals: Learn to Query a Database

SQL Fundamentals (SELECT, Filters, Aggregates) is a beginner-level course of 5 lessons (about 2 h 9 min), with 17 exercises and 15 quiz questions. No prerequisites. Exercises run in the browser, with nothing to install.

  • SQL
  • Beginner
  • 5 lessons
  • 2 h 9 min
  • 17 exercises
  • Exercises run in the browser

The course in brief

This introductory course teaches you to write your first SQL queries, right in the browser. You will read tables, filter rows, sort results and calculate metrics (totals, averages, counts) by group. It is the common foundation of all data, BI and web development paths.

What you will be able to do

  • Write SELECT queries with chosen columns, calculated columns and aliases
  • Filter rows with WHERE, AND/OR, IN, BETWEEN, LIKE and IS NULL
  • Sort, deduplicate and paginate a result with ORDER BY, DISTINCT, LIMIT and OFFSET
  • Calculate metrics with COUNT, SUM, AVG, MIN and MAX while mastering the effect of NULLs
  • Produce summary tables with GROUP BY and HAVING
  • Know the logical order of execution of an SQL query

Syllabus: 5 lessons

  1. 01

    First Queries: SELECT and FROM

    15 minFree preview
    • Understand what a relational table is (rows, columns, types)
    • Write a SELECT ... FROM query to read chosen columns
    • Create calculated columns and rename them with AS
    • Limit the number of rows displayed with LIMIT

    SELECT and FROMColumn aliases (AS)Calculated columnsLIMIT

  2. 02

    Filtering Rows with WHERE

    18 min
    • Filter rows with comparisons in WHERE
    • Combine conditions with AND, OR, NOT and parentheses
    • Use IN, BETWEEN, LIKE and IS NULL

    WHERE clauseAND, OR, NOTIN, BETWEEN, LIKETesting NULL with IS NULL

  3. 03

    Sorting and Deduplicating: ORDER BY and DISTINCT

    15 min
    • Sort a result on one or more columns with ORDER BY
    • Get unique values with DISTINCT
    • Build a "top N" with ORDER BY and LIMIT, and paginate with OFFSET

    ORDER BYDISTINCTTop N with LIMIT and OFFSET

  4. 04

    Summarizing Data: Aggregate Functions

    16 min
    • Calculate a total, an average, a minimum and a maximum
    • Distinguish COUNT(*), COUNT(column) and COUNT(DISTINCT column)
    • Understand how aggregates treat NULL values

    COUNT, SUM, AVG, MIN, MAXCOUNT(DISTINCT)NULL and aggregates

  5. 05

    Grouping with GROUP BY and Filtering with HAVING

    20 min
    • Calculate aggregates per group with GROUP BY
    • Filter groups with HAVING
    • Distinguish WHERE (rows) from HAVING (groups) and know the logical order of execution

    GROUP BYHAVINGLogical order of execution

Final project

SQL Dashboard for a Small Shop

You receive a shop's products and sales tables (same structures as in the course, with more rows). The manager asks you for a series of commented queries to run the business: valued inventory, products to restock, product ranking, overall metrics, revenue by city, by salesperson and by month, and identification of weak segments.

Deliverables

  • A .sql file containing at least 8 queries, each preceded by a comment explaining the business question
  • A valued inventory query (prix * stock) sorted by descending value
  • A query listing products that are out of stock or have unknown stock
  • Overall metrics: number of sales, revenue, rounded average basket, number of distinct salespeople
  • Summaries by city, by salesperson and by month, including at least one using HAVING
  • A short paragraph explaining how NULL amounts were handled

Assessment criteria

  • Queries run without errors and answer exactly the question asked
  • NULLs are handled explicitly (IS NULL, COUNT(*) vs COUNT(column), COALESCE)
  • WHERE and HAVING are used appropriately
  • Displayed results are sorted and calculated columns are named with clear aliases
  • The code is readable: indentation, uppercase keywords, comments

Frequently asked questions

Do I need to know how to program to take this SQL course?

No. The course starts from zero: you write queries directly in the browser, with nothing to install, and every concept comes with exercises that have solutions.

Which database engine is used?

The exercises run on SQLite. The concepts covered (SELECT, WHERE, GROUP BY...) are standard and also apply to PostgreSQL, MySQL or SQL Server; the few differences are pointed out.

How long does it take to learn the basics of SQL?

Allow about an hour and a half for the five lessons and their exercises, plus the final project. Regular practice remains the key to feeling comfortable.

What is SQL used for in a data or web job?

SQL lets you extract and summarize the data stored in a company's databases. It is a skill sought in data analysts, BI analysts, data scientists and back-end developers.

This course, told for your job

Say what you want to be able to do: “SQL Fundamentals (SELECT, Filters, Aggregates)” takes its place in your path, with examples from your field. The concepts stay those of the course.

The preview is free, and you can take the courses one at a time without paying. The path only contains lessons from the catalogue.