SQL Query Cheat Sheet | Copy-Paste Library, Data Analyst Reference (XLSX)
SQL QUERY CHEAT SHEET & COPY-PASTE LIBRARY
50+ ready-to-paste SQL queries across 8 topic sheets
Built by a WGU MS Data Analytics graduate from real project work — including SQL I wrote to query 500+ daily access control records at Allied Universal and database queries behind a live AI dashboard now serving 200+ users.
Open it. Find your query. Copy it. Replace the [bracketed items] with your table and column names. Run it. That's the whole process. Works in Microsoft Excel and Google Sheets.
─────────────────────────────────────────────
WHAT'S INSIDE — 8 SHEETS
─────────────────────────────────────────────
SHEET 1 — BASIC SELECTS (15 queries)
SELECT *, specific columns, WHERE filters, AND/OR, LIMIT, ORDER BY, DISTINCT, LIKE, IN lists, BETWEEN ranges, NULL checks, NOT NULL, column aliases
SHEET 2 — AGGREGATIONS & GROUP BY (10 queries)
COUNT, SUM, AVG, MIN & MAX, GROUP BY, HAVING filter, percent of total, multiple aggregations at once
SHEET 3 — ALL JOIN TYPES (8 queries)
INNER JOIN, LEFT JOIN, RIGHT JOIN, FULL OUTER JOIN, three-table join, self join, join with filter, find missing records
SHEET 4 — DATE & TIME (8 queries)
Date range filter, last 30 days, this year, EXTRACT year/month, monthly trend with DATE_TRUNC, day of week, days between dates
SHEET 5 — WINDOW FUNCTIONS ADVANCED (10 queries)
Running total SUM OVER, ROW_NUMBER, RANK, DENSE_RANK, PARTITION BY, LAG prior row, month-over-month change, 7-day rolling average, NTILE quartiles, LEAD next row
SHEET 6 — DATA CLEANING (9 queries)
Find NULLs, NULL summary, find duplicates, COALESCE, TRIM, UPPER/LOWER/INITCAP, type casting, remove duplicates, string REPLACE
SHEET 7 — BUSINESS ANALYSIS TEMPLATES (7 queries)
Revenue by region, top N customers, repeat buyers, month-over-month growth rate, inventory status, churn by recency, access control audit (real Allied Universal query)
SHEET 8 — CTEs & SUBQUERIES (6 patterns)
Basic CTE, chained CTEs, subquery in WHERE, subquery in FROM, correlated subquery, recursive CTE for org hierarchy
─────────────────────────────────────────────
HOW TO USE IT
─────────────────────────────────────────────
Step 1 — Download .xlsx after purchase. Open in Excel or Google Sheets.
Step 2 — Click the tab for your query type.
Step 3 — Copy the full query from the "COPY-PASTE SQL QUERY" column.
Step 4 — Replace [table_name] and [col_name] with your actual names.
Step 5 — Paste into your SQL editor (pgAdmin, SSMS, DBeaver, Mode, BigQuery) and run.
Compatible with: PostgreSQL, MySQL, SQLite, DuckDB, SQL Server, BigQuery, Snowflake, Redshift.
─────────────────────────────────────────────
THIS IS FOR YOU IF...
─────────────────────────────────────────────
✓ You're learning SQL and want real examples, not textbook theory
✓ You're a career changer into data needing a practical reference
✓ You query databases regularly and want faster copy-paste access
✓ You're a WGU, bootcamp, or self-taught learner building a portfolio
─────────────────────────────────────────────
FILE DETAILS
─────────────────────────────────────────────
File format: .xlsx | Compatible: Excel 2016+, Google Sheets
Delivery: Instant download after purchase | License: Single-user
─────────────────────────────────────────────
ABOUT THE CREATOR
─────────────────────────────────────────────
Built by Shanikwa — MS Data Analytics, Western Governors University.
Portfolio: analyticsbyshanikwa.com | GitHub: github.com/ShanikwaH/WGU_Portfolio
─────────────────────────────────────────────
Questions before buying? Message me — I respond within 24 hours.
⭐ Also in the Data Analyst Complete Bundle (4 tools for $25).
All sales final for digital items. Technical issues resolved within 24 hours.