SQL · CHEAT SHEET

SQL Core Cheat Sheet

SELECT, WHERE, JOIN, GROUP BY, HAVING, CASE, ORDER BY and LIMIT patterns for daily analysis.

FilterWHERE Status = 'Open'
PatternWHERE Code LIKE 'AK%'
GroupGROUP BY Material
Post-filterHAVING COUNT(*) > 1
Missing matchLEFT JOIN ... WHERE right.Key IS NULL
Latest rowROW_NUMBER() OVER(PARTITION BY Key ORDER BY Time DESC)

Use the pattern, then verify the result

Cheat sheets are reminders, not substitutes for checking keys, data types, duplicates and edge cases. Follow the linked learning material when a pattern is new to you.