Kept running into the same problem when I was learning SQL — tutorials teach you one concept at a time but you never have everything in one place when you actually need it.
So I made a one-page reference. Here's a chunk of it:
**SELECT & Filter**
SELECT column1, column2 FROM table WHERE condition;
SELECT DISTINCT column FROM table;
SELECT * FROM table WHERE column LIKE '%pattern%';
SELECT * FROM table WHERE column IN ('val1', 'val2');
SELECT * FROM table WHERE column BETWEEN 10 AND 50;
**Aggregations**
SELECT COUNT(*), AVG(salary), SUM(revenue)
FROM table
GROUP BY department
HAVING COUNT(*) > 5;
**JOINs**
-- INNER: only matching rows
SELECT * FROM orders o INNER JOIN customers c ON o.customer_id = c.id;
-- LEFT: all from left table + matches from right
SELECT * FROM customers c LEFT JOIN orders o ON c.id = o.customer_id;
**CTEs**
WITH top_earners AS (
SELECT name, salary, RANK() OVER (ORDER BY salary DESC) as rnk
FROM employees
)
SELECT * FROM top_earners WHERE rnk <= 10;
The full version also covers window functions, CASE statements, date functions, string manipulation, and indexing tips — all on one printable page.
What else would you want on a SQL cheat sheet? Trying to make sure I'm not missing anything obvious.
---
Edit: Lot of people asking for the full version. DM me and I'll send you the link.