AI Hints
Home›SQL Tutorial
Free course

SQL Tutorial

Learn SQL from absolute zero, one small and easy step at a time. No experience needed. Every query is run for real on a small online bookshop database, so you see exactly what each line does. 📂 Download the practice database (shop.db): https://aihints.com/data/sql/shop.db

📚 126 lessons▶ 3:00:10+ of video💻 246 code examples🖼 133 screenshots
The complete SQL course, free on YouTubeWatch on YouTube ↗

Course contents

Every lesson has its own page with the explanation, code you can copy, the real output, screenshots from the video, and a link that jumps straight to that moment in the video.

2. Your First Queries

  1. Your First SELECT4:36
  2. Choosing Columns6:04
  3. Just a Few Rows7:37

5. Ranges, Patterns and Missing Values

  1. Ranges with BETWEEN18:50
  2. Patterns with LIKE19:59
  3. Missing Values: NULL21:19

14. Inner and Left Joins

  1. Inner Joins Drop Rows1:03:27
  2. LEFT JOIN1:04:39
  3. Finding What Is Missing1:06:10

15. Joining Many Tables

  1. Joining Three Tables1:07:40
  2. Revenue with Joins1:09:26
  3. Practice: Revenue by Country1:10:52

16. More Kinds of Join

  1. Self Joins1:12:16
  2. RIGHT, FULL, and CROSS Joins1:13:36
  3. The Double Counting Trap1:14:59

18. CTEs, EXISTS, and Set Operations

  1. Common Table Expressions1:22:59
  2. Chaining CTEs1:24:24
  3. EXISTS1:25:29
  4. UNION, INTERSECT, and EXCEPT1:26:39

19. Window Functions

  1. Window Functions1:28:54
  2. ROW_NUMBER1:30:35
  3. RANK and DENSE_RANK1:31:24
  4. Top N per Group1:32:34

20. Running Totals and Trends

  1. Running Totals1:33:50
  2. LAG and LEAD1:35:14
  3. Moving Averages and NTILE1:36:16
  4. Practice: Who Brings the Money?1:37:22

21. Creating and Changing Data

  1. Creating Tables1:38:51
  2. Adding Rows1:40:15
  3. Changing Rows1:41:18
  4. Deleting Rows1:42:40

22. Rules, Safety, and Speed

  1. Constraints1:44:04
  2. Transactions1:45:50
  3. Views and ALTER TABLE1:46:57
  4. Indexes1:48:09

23. Designing Databases

  1. Designing Good Tables1:49:27
  2. Design Practice: Event Bookings1:51:18
  3. SQL Dialects1:52:27

24. Project: The Monthly Report

  1. Project 1: The Monthly Report1:53:47
  2. Monthly Numbers1:55:16
  3. Best Sellers of the Month1:56:41

25. Project: The Customer Report

  1. Project 2: The Customer Report1:58:31
  2. Customer Segments2:00:31
  3. Repeat Buyers2:01:46

26. Project: The Stock Alert

  1. Project 3: The Stock Alert2:03:07
  2. Months of Stock Left2:04:47

27. Cleaning Messy Data

  1. Cleaning Messy Data2:06:53
  2. Cleaning Text2:08:29
  3. Blanks and Numbers2:09:31
  4. Removing Duplicates2:11:05

28. Interview Questions, Part 1

  1. Interview Questions, Part 12:13:04
  2. Employees and Managers2:14:20
  3. Finding Duplicates2:15:11
  4. The NOT IN Trap2:16:08

29. Interview Questions, Part 2

  1. Interview Questions, Part 22:17:24
  2. Percentages of a Total2:18:21
  3. Time Between Orders2:19:58
  4. Retention2:21:04

30. Interview Questions, Part 3

  1. Interview Questions, Part 32:22:18
  2. More Theory Questions2:23:46
  3. Quick-Fire Quiz2:25:13

31. Reading Error Messages

  1. Reading Error Messages2:27:34
  2. Syntax Errors2:28:49
  3. Ambiguous and Misused2:30:03
  4. Silent Mistakes2:31:14

32. Pivots, Lists, and Recursion

  1. Pivot Tables in SQL2:32:43
  2. Lists in One Cell2:34:04
  3. Recursive CTEs2:34:59
  4. Filling Gaps in Dates2:36:18

33. Final Project: The Year in Review

  1. Final Project: The Year in Review2:37:35
  2. Growth and Stars2:39:25
  3. What Is Going Wrong?2:40:24

34. Practice Gym: The Basics

  1. Practice Gym: The Basics2:42:31
  2. Gym: Nulls, Maths, and CASE2:44:58
  3. Gym: Dates2:47:15

35. Practice Gym: Groups and Joins

  1. Practice Gym: Groups and Joins2:48:01
  2. Gym: Join Workout2:49:48
  3. Gym: Four Tables2:51:52

36. Practice Gym: Windows and CTEs

  1. Practice Gym: Windows and CTEs2:52:46
  2. Gym: Trends and Sizes2:54:41
  3. Gym Reflection2:56:14

37. Recap and Roadmap

  1. Your SQL Cheat Sheet2:56:56
  2. Your Roadmap2:59:02
  3. Final Quiz3:00:10