SQL Essentials: Think in Tables

Software
SQL
Data Science
Learn the relational mental model, core SQL clauses, joins and aggregation with high-quality interactive practice.
Author

MLStation

Published

October 1, 2026

SQL is not merely another programming syntax. Its superpower is that you describe the result you want from relational data.

TipKey ideas

table row column primary key foreign key SELECT WHERE GROUP BY HAVING ORDER BY JOIN NULL aggregate

The mental model

FROM / JOIN   → Which data?
WHERE         → Which rows?
GROUP BY      → Which groups?
HAVING        → Which groups survive?
SELECT        → What output?
ORDER BY      → In what order?

Example:

SELECT department,
       AVG(salary) AS avg_salary
FROM employees
WHERE active = TRUE
GROUP BY department
HAVING COUNT(*) >= 5
ORDER BY avg_salary DESC;

Start here

★ SQLBolt

Excellent first resource because lessons and exercises run interactively in the browser.

https://sqlbolt.com/

★ PostgreSQL Tutorial

A more formal path through relational concepts, queries, joins, aggregates and advanced features.

https://www.postgresql.org/docs/current/tutorial.html

★ SQLite Tutorial / Docs

Useful when you want a lightweight local database requiring little setup.

https://www.sqlite.org/docs.html

Practice order

SELECT
 ↓
WHERE + ORDER BY
 ↓
GROUP BY + aggregates
 ↓
INNER / LEFT JOIN
 ↓
CASE
 ↓
subqueries / CTEs
 ↓
window functions
TipData Scientist checkpoint

If you can confidently combine JOIN + GROUP BY + CASE + window functions, you can solve a large fraction of everyday analytical SQL tasks.

Practice

  • SQLBolt: https://sqlbolt.com/
  • HackerRank SQL: https://www.hackerrank.com/domains/sql
  • LeetCode Database problems: https://leetcode.com/problemset/database/

Next: Analytical SQL & Interview Patterns

Back to top