Back to Cheat SheetsData · Beginner
SQL cheat sheet
Queries, joins and aggregations testers need for data verification.
Query basics
Select + filter
SELECT id, email FROM users WHERE status = 'active';Sort + limit
ORDER BY created_at DESC LIMIT 10;Pattern / null
WHERE email LIKE '%@test.io' AND deleted_at IS NULLJoins
Inner join
Only matching rows
FROM orders o JOIN users u ON u.id = o.user_idLeft join
Find orphans with p.id IS NULL
LEFT JOIN payments p ON p.order_id = o.idAggregation
Group by
SELECT status, COUNT(*) FROM orders GROUP BY status;Having
GROUP BY user_id HAVING COUNT(*) > 3;Duplicates
SELECT email, COUNT(*) FROM users GROUP BY email HAVING COUNT(*) > 1;Go beyond the reference
Book a free demo class and apply these commands on live project work.