SQL
Think in SQL
From your first SELECT to window functions, JSON and pipelines
The book
Learn SQL from Zero to Hero with Datasets and an Enterprise-Level Practice Website
by Kapil Dev V
A patient, hands-on SQL book on PostgreSQL. It explains each idea in plain words and walks through every result, using one shop's realistic data from start to finish. Every query it prints runs on the SQL Playground, where you need nothing installed and pay nothing.
The book is being prepared for Amazon (Kindle, paperback and hardcover) and Google Play Books. Links to buy it will be here once it is out.
The SQL Playground at kdvtutors.org was built for this book, and it runs every query the book asks you to run.
The book's five tables of an online shop: customers, products, transactions, payments (pg_data) and cashback rewards. Shared and read-only, so no query can break them.
PostgreSQL running in your own browser for the chapters that create tables and change rows. Copy the storefront into it with one click, and export it to a .sql file.
Each query the book prints, numbered as in the book (4.3 is chapter 4's third), opens in the editor on the database the book runs it on.
Every exercise prints a check value. The site compares your result with it, says which number differs, and ticks the exercise off in your skill tree.
Two sessions taking turns for the transactions chapter, a job on a schedule, and a toy login to try SQL injection on, pasted and safely bound.
EXPLAIN drawn as a tree, with estimated and actual rows side by side, and million-row tables to watch an index change a plan.
When a query fails, the site shows the book's card for that error: the usual cause and the fix.
A data dictionary for every column, and the five tables to download as CSV, masked as the book prints them, under CC BY 4.0.
The tables, their columns and the downloads are on the Datasets page, open to everyone.
The code gives you 180 days of access, free, counted from the day you create your account. No book? You can buy a code instead.
Create an account