warming up your workspace

SQL Foundations through SQL Analytics

Never queried a database before? Start here. You will learn to read tables, filter and sort rows, summarize with aggregates, and join tables, all through a small shop dataset. By the end you are ready for Project 1.

Reading a table

  1. SELECT *: read the whole table
  2. Pick the columns you want
  3. AS: rename a column
  4. DISTINCT: drop duplicates
  5. Compute a new column

Choosing rows

  1. WHERE: keep matching rows
  2. Compare numbers
  3. AND / OR: combine conditions
  4. BETWEEN: a range
  5. LIKE: match text patterns

Sorting and limiting

  1. ORDER BY: sort the rows
  2. DESC: largest first
  3. Sort by two columns
  4. LIMIT: just the first few
  5. Top N: order then limit

Summarizing data

  1. COUNT: how many rows?
  2. SUM and AVG
  3. MIN and MAX
  4. GROUP BY: summarize per category
  5. HAVING: filter the groups

Combining tables

  1. A second table, linked by id
  2. JOIN: stitch two tables
  3. Pull columns from both tables
  4. Filter a joined result
  5. Capstone: who spends the most?

Explore the full field