learning-it by example

Back to the video

SQL in 10 Queries: From SELECT to LEFT JOIN

Ten SQL queries on one small shop: a left join finds the 1 customer who never ordered.

Video #297 ยท SQL and analytics

Steps in the video

  1. 0:00 Ten queries, one small shop, and one customer who never ordered
  2. 0:31 The idea
  3. 0:55 Setup
  4. 1:16 The made-up shop
  5. 1:42 Three tables
  6. 2:06 Queries one to six
  7. 2:33 The loop
  8. 3:45 Joins, totals and a parameter
  9. 5:02 What this does not show
  10. 5:25 Mistakes to avoid
  11. 5:53 My take and next steps
  12. 6:17 Recap

Files

  • queries.py (24 lines)
  • run.py (12 lines)
  • shop.py (25 lines)

Download the code (zip)

Tested with

Python 3.12.15

What this does not show

The shop data is made up and tiny, so the video says nothing about speed or indexes; it does not cover insert beyond setup, update, delete, dates, subqueries or right and full joins.

Sources

Learning IT by Example.