Wicked Smart Data
LearnInsightsAboutContact
Sign InLet's Build
LearnInsightsAboutContact
Sign InLet's Build
Wicked Smart Data

Intelligence, automation, and expert execution — plus an elite library of free knowledge. We turn complexity into competitive advantage.

Start a conversation

Platform

  • Learning Paths
  • Insights
  • RSS Feed

Company

  • About
  • Contact
  • Work With Us

Legal

  • Privacy Policy
  • Terms of Service

© 2026 Wicked Smart Data. All rights reserved.

Intelligence · Automation · Advantage

SQL
Learning Path⚡ Practitioner

Advanced SQL Queries

Window functions, CTEs, query plans, and performance tuning.

1
Lesson 1

Window Functions: RANK, ROW_NUMBER, and LAG

18 min read
2
Lesson 2

Common Table Expressions (CTEs) for Cleaner SQL

23 min read
3
Lesson 3

Advanced CTEs: Recursive Queries and Hierarchical Data

Master recursive Common Table Expressions to query organizational hierarchies, product categories, and any tree-structured data with practical, real-world examples.

14 min read
4
Lesson 4

Advanced Pivoting and Unpivoting Data Transformations in SQL

Master enterprise-scale data reshaping with dynamic pivots, performance optimization, and integration patterns for modern data architectures. Includes real-world examples and advanced troubleshooting techniques.

27 min read
5
Lesson 5

Pivoting and Unpivoting Data in SQL: Transform Your Data Shape Like a Pro

Master SQL's PIVOT and UNPIVOT operations to transform row data into columns and vice versa. Learn dynamic pivoting, real-world applications, and troubleshooting tips for reshaping your data effectively.

15 min read
6
Lesson 6

SQL Query Optimization: Reading Execution Plans - Advanced Performance Analysis

Master the art of reading database execution plans to diagnose performance bottlenecks and optimize complex queries. Learn advanced techniques for analyzing costs, operators, and optimization patterns across different database systems.

21 min read
7
Lesson 7

Stored Procedures and User-Defined Functions: Building Reusable SQL Logic

Transform repetitive SQL tasks into efficient, maintainable database objects. Learn to create stored procedures and functions that save time, reduce errors, and organize your SQL code professionally.

14 min read
8
Lesson 8

SQL Transactions, Isolation Levels, and Locking: A Complete Guide to Concurrent Database Programming

Master the essential concepts of database transactions, isolation levels, and locking mechanisms. Learn to build robust, concurrent applications that maintain data integrity under load with practical examples and real-world scenarios.

17 min read
9
Lesson 9

Advanced JOIN Patterns: Self Joins, Anti Joins, and Semi Joins

Master the advanced SQL JOIN patterns that separate expert practitioners from the rest. Learn self joins for hierarchical data, anti joins for exclusion logic, and semi joins for existence checks.

20 min read
10
Lesson 10

Working with JSON and Arrays in Modern SQL: Complete Guide

Master JSON and array operations in SQL databases. Learn to query, extract, and manipulate semi-structured data using native SQL functions and JSONPath expressions.

14 min read
11
Lesson 11

SQL for Data Analysis: Cohort Analysis, Funnels, and Retention - Complete Guide

Master sophisticated SQL techniques for user behavior analysis including cohort tracking, conversion funnels, and retention metrics that drive product decisions at data-driven companies.

17 min read
12
Lesson 12

Database Performance Tuning: Advanced Indexing Strategies and Query Rewriting for Production Systems

Master the art and science of database performance optimization through strategic indexing, query rewriting techniques, and systematic optimization approaches that transform slow queries into lightning-fast operations.

20 min read
13
Lesson 13

Subqueries and Correlated Subqueries: Writing Queries Within Queries

Stop writing two-step workarounds and start writing SQL that answers layered questions in a single statement. This lesson teaches you exactly how subqueries work, where to place them, and how correlated subqueries let you compare each row against its own group — with real examples you can run immediately.

15 min read
14
Lesson 14

Temporal Data Mastery: Writing Queries for Time-Series, Date Ranges, and Slowly Changing Dimensions

Temporal data is where SQL skills separate practitioners from experts. This lesson teaches you to write production-quality queries for time-series aggregations, gap-filling, point-in-time lookups, and Slowly Changing Dimensions — the four categories of temporal problems every serious data team faces. Leave with patterns you can apply immediately.

21 min read
15
Lesson 15

Mastering SQL Set Operations: UNION, INTERSECT, and EXCEPT for Complex Data Reconciliation and Deduplication

SQL set operations are the most underutilized tool in the data professional's toolkit. This expert-level lesson teaches you the relational algebra foundations, performance internals, and production-ready patterns for using UNION, INTERSECT, and EXCEPT to solve real data reconciliation problems — including a complete, working migration audit framework.

28 min read
16
Lesson 16

Conditional Aggregation with CASE WHEN: Pivoting Logic Without Reshaping Your Data

Learn how to use CASE WHEN inside aggregate functions to create pivot-style reports, segment metrics, and answer multi-part business questions in a single SQL query — no spreadsheet exports required. This lesson builds the technique from first principles with realistic, hands-on examples.

14 min read
17
Lesson 17

Dynamic SQL: Writing and Executing Parameterized Queries at Runtime

Static SQL can't handle optional filters, variable column lists, or runtime table selection — dynamic SQL can. This deep-dive lesson teaches you to write parameterized dynamic SQL that's safe, performant, and production-ready, covering sp_executesql, injection prevention, optional filter procedures, and dynamic pivots.

24 min read
18
Lesson 18

Advanced Window Frame Specifications: ROWS, RANGE, and GROUPS Clauses for Precise Rolling Calculations

Most SQL practitioners use ROWS out of habit without realizing that RANGE and GROUPS exist, or that the wrong choice can silently corrupt rolling aggregates. This expert lesson dives into the mechanics, edge cases, and performance implications of all three window frame modes so you can choose — and defend — the right one every time.

30 min read
19
Lesson 19

Writing Efficient SQL Aggregations: GROUP BY, HAVING, and Grouping Sets Explained

Aggregation is how you turn millions of raw rows into the summaries that actually drive decisions. This lesson teaches you how GROUP BY, HAVING, ROLLUP, and CUBE work from first principles — so you can write correct, efficient aggregation queries on any database.

16 min read
20
Lesson 20

Lateral Joins and CROSS APPLY: Row-by-Row Subquery Power in SQL

Standard SQL joins can't reference the current outer row inside a subquery — lateral joins and CROSS APPLY break that limitation wide open. Learn how they work, when to use them, and how to write them for real-world data transformation problems across PostgreSQL, SQL Server, MySQL, and BigQuery.

23 min read
21
Lesson 21

Query Optimization with Materialized Views: Caching Complex Aggregations and Refreshing Strategies for High-Performance Analytics

Materialized views can turn a 45-second dashboard query into a sub-second one — but only if you understand the storage mechanics, design your aggregations at the right granularity, and choose the right refresh strategy for your availability requirements. This deep-dive lesson covers everything from PostgreSQL internals to multi-tier dependency graphs and cross-platform patterns in Snowflake and BigQuery.

29 min read
22
Lesson 22

Filtering and Transforming Data with SQL String Functions: LIKE, REGEXP, SUBSTRING, and REPLACE

Real-world data is messy — inconsistent formats, buried values, and text that doesn't match any standard. This lesson teaches you how to use SQL's core string functions to filter, extract, and clean text data with precision. By the end, you'll be writing queries that turn chaotic string columns into structured, usable information.

15 min read
23
Lesson 23

Fuzzy Matching and Deduplication in SQL: Using Similarity Functions and Blocking Strategies to Find Near-Duplicate Records

Exact-match SQL queries can't catch "Jon Smith" and "John Smith" as the same person. This hands-on lesson teaches you to build a complete fuzzy deduplication pipeline using similarity functions, smart blocking strategies, and composite scoring — on tables with hundreds of thousands of rows. Walk away with production-ready SQL you can actually use.

22 min read
24
Lesson 24

Graph Traversal in SQL: Recursive CTEs and Adjacency Lists for Network and Relationship Analysis

Recursive CTEs unlock graph traversal natively in SQL — no application code required. Learn how they actually execute, how to traverse hierarchies in both directions, detect cycles, reconstruct paths, and roll up subtree aggregates, with realistic examples from org charts, bill of materials, and network graphs.

31 min read
25
Lesson 25

Understanding SQL NULL Handling: COALESCE, NULLIF, and IS NULL for Reliable Data Queries

NULL values silently break more SQL queries than most people realize. This lesson teaches you how NULL actually works, why `= NULL` never matches, and how to use COALESCE, NULLIF, and IS NULL to write queries that handle missing data correctly every time.

15 min read
26
Lesson 26

Multi-Level Aggregation with ROLLUP, CUBE, and GROUPING SETS: Building Summary Reports and Cross-Dimensional Totals

Stop writing brittle UNION ALL chains to produce summary reports. Learn how ROLLUP, CUBE, and GROUPING SETS let you compute hierarchical subtotals, cross-dimensional totals, and grand totals in a single query pass — and how to use GROUPING() to make the results actually readable.

24 min read
27
Lesson 27

Advanced SQL Security: Row-Level Security, Dynamic Data Masking, and Permission-Based Query Filtering for Multi-Tenant Applications

Most multi-tenant SQL security fails not because of missing features, but because engineers bolt security onto the application layer instead of enforcing it at the database level. This lesson teaches you to implement Row-Level Security, Dynamic Data Masking, and permission-based query filtering in PostgreSQL and SQL Server — security that holds even when your application code has bugs.

28 min read
28
Lesson 28

Joining Multiple Tables in SQL: INNER, LEFT, RIGHT, and FULL OUTER JOIN Explained

Most real-world SQL questions require data from multiple tables — and how you join them determines everything. This lesson breaks down every JOIN type with realistic examples, so you'll know exactly which one to reach for and why.

16 min read
29
Lesson 29

Bulk Data Loading and Upsert Patterns in SQL: MERGE, INSERT ON CONFLICT, and Incremental Load Strategies for Production Pipelines

Truncate-and-reload stops working the moment your tables hit serious scale. This lesson teaches you MERGE, INSERT ON CONFLICT, staging table patterns, and incremental load strategies that production pipelines actually use — complete with row hashing, deduplication, and batching techniques.

21 min read
30
Lesson 30

Analytical Query Patterns with FILTER, WITHIN GROUP, and Ordered-Set Aggregates for Advanced Statistical Reporting

Most SQL developers know these features exist but never fully internalize them. This deep-dive lesson teaches you how to combine FILTER, WITHIN GROUP, PERCENTILE_CONT, PERCENTILE_DISC, and MODE into single-pass statistical reports that replace complex multi-query pipelines. Learn the execution model, edge cases, and performance trade-offs that separate expert SQL from advanced SQL.

27 min read
31
Lesson 31

Datetime Arithmetic and Interval Calculations in SQL: Converting, Truncating, and Computing Durations Across Database Platforms

Dates and times are everywhere in data work, but SQL's datetime functions vary wildly across platforms — and the edge cases produce wrong answers that look right. This lesson teaches you how to cast, truncate, and subtract dates, and how to use interval arithmetic across PostgreSQL, MySQL, BigQuery, and SQL Server.

14 min read
32
Lesson 32

Partitioning Strategies in SQL: Using Table Partitioning and Partition Pruning to Accelerate Queries on Large Datasets

When indexes alone stop being enough, table partitioning is the next level of SQL performance engineering. Learn how to design range, list, and hash partitioning strategies, verify partition pruning is actually working, and avoid the subtle mistakes that silently kill performance on large datasets.

24 min read
33
Lesson 33

Query Rewriting with Common Subexpression Elimination: CTEs, Derived Tables, and Optimizer Hints for Maximum SQL Performance

Repeated subexpressions in SQL don't just hurt readability — they silently multiply your database's workload, often by 3x to 7x on large tables. This expert lesson teaches you to identify, factor, and verify common subexpression elimination using CTEs, derived tables, temp tables, and engine-specific optimizer hints across PostgreSQL, SQL Server, Oracle, and BigQuery.

28 min read
34
Lesson 34

Writing Readable SQL: Formatting, Aliasing, and Structuring Complex Queries

Unreadable SQL is one of the most common and costly problems in data teams. This lesson teaches you the formatting conventions, aliasing strategies, and CTE-based structure patterns that make your queries maintainable by anyone — including yourself six months from now.

16 min read
35
Lesson 35

Statistical Aggregations in SQL: PERCENTILE, MEDIAN, STDDEV, and Variance Functions for Data Analysis

Averages are only the beginning. This in-depth lesson teaches you how to use SQL's statistical aggregation functions — PERCENTILE_CONT, STDDEV, VAR_SAMP, and more — to analyze data distributions, detect outliers, and build professional distribution reports. Covers PostgreSQL, BigQuery, and SQL Server with real-world examples.

21 min read
36
Lesson 36

Query Profiling and Statistics in SQL: Using EXPLAIN ANALYZE, Buffer Metrics, and Row Estimates to Diagnose Slow Queries

Most slow SQL queries aren't fixed by random index additions — they're fixed by reading what the query planner is actually telling you. This expert-level lesson teaches you to systematically diagnose any slow query using EXPLAIN ANALYZE, buffer metrics, and PostgreSQL's statistics system, so you stop guessing and start solving.

29 min read
37
Lesson 37

Aggregating Across Groups with SQL Window Functions: SUM, AVG, and COUNT OVER PARTITION BY

Learn how SQL window functions let you compute group totals, averages, and counts without collapsing your rows. This hands-on lesson teaches SUM, AVG, and COUNT with OVER PARTITION BY using realistic business scenarios — so you'll actually understand when and why to use them.

15 min read
38
Lesson 38

Writing Effective SQL Unit Tests: Validating Query Logic, Edge Cases, and Data Contracts in CI/CD Pipelines

SQL bugs don't throw exceptions — they return wrong answers silently. This lesson teaches you how to build a complete SQL unit testing strategy using fixture data, edge case coverage, data contracts, and CI/CD integration with dbt and GitHub Actions.

24 min read
39
Lesson 39

Advanced SQL Anti-Patterns: Identifying and Refactoring Common Query Mistakes That Kill Performance at Scale

Slow queries rarely fail — they just silently drain your system's resources until something breaks. This expert-level guide covers eight of the most damaging SQL anti-patterns, with real execution plan analysis, refactored examples, and a practical checklist for reviewing production queries before they become incidents.

27 min read
40
Lesson 40

Indexing Fundamentals for Query Performance: How to Choose, Create, and Evaluate Indexes on Real Tables

Slow queries are almost always an indexing problem. This lesson teaches you exactly how B-tree indexes work, how to choose the right columns to index, and how to verify that your indexes are actually being used — with real SQL examples from a production-scale table.

16 min read
41
Lesson 41

Incremental Query Design with Watermark Tables and Change Data Capture: Tracking and Processing Only New or Modified Records in SQL Pipelines

Full-reload ETL jobs that process millions of unchanged rows are a solved problem — if you know the patterns. This lesson teaches production-grade incremental pipeline design using watermark tables and Change Data Capture, with complete SQL code for handling updates, deletes, and failure recovery.

25 min read
42
Lesson 42

Polymorphic Associations and Entity-Attribute-Value Patterns in SQL: Modeling and Querying Flexible Schemas Without Sacrificing Performance

Flexible schemas in relational databases are a genuine engineering challenge — not a problem to avoid, but one to solve deliberately. This lesson teaches you the mechanics, trade-offs, and performance strategies for polymorphic associations and EAV patterns, including modern alternatives like JSONB and hybrid architectures.

29 min read
43
Lesson 43

Mastering SQL Joins with Aggregates: Combining GROUP BY, COUNT, and SUM Across Related Tables

Learn how to combine SQL joins with GROUP BY, COUNT, and SUM to answer real business questions across multiple related tables. This lesson covers fan-out pitfalls, LEFT JOIN behavior with HAVING, and how to structure complex queries with CTEs.

16 min read
44
Lesson 44

Multitenancy Query Patterns in SQL: Schema-Per-Tenant, Shared Tables, and Efficient Cross-Tenant Reporting Strategies

Building a multitenant SQL database means every query carries a security contract. This lesson teaches you the three major isolation models, how to write tenant-safe queries with proper indexing, and how to build cross-tenant analytics that scale without leaking data.

21 min read
45
Lesson 45

Deterministic and Nondeterministic Functions in SQL: Understanding Volatility Categories and Their Impact on Query Planning, Caching, and Index Usage

Most SQL developers treat functions as black boxes — but the database treats them as contracts. Learn how PostgreSQL's IMMUTABLE, STABLE, and VOLATILE classifications shape query planning, index eligibility, and caching behavior, and how getting this wrong silently destroys performance or corrupts results.

30 min read
46
Lesson 46

Subquery Factoring and Inline Views: When to Use Derived Tables, Scalar Subqueries, and EXISTS for Readable and Efficient Filtering

Mastering subquery patterns is the inflection point between writing SQL that works and SQL that scales. This lesson teaches you when to use derived tables, scalar subqueries, and EXISTS filters — with real examples and the performance reasoning behind each choice.

16 min read
47
Lesson 47

Geospatial Queries in SQL: Using PostGIS and Spatial Functions to Filter, Measure, and Join Location-Based Data

PostGIS turns PostgreSQL into a full-featured spatial database. Learn how to store, index, filter, measure, and join location data using geometry types, spatial predicates, and real-world radius and polygon queries — with production-grade performance patterns included.

22 min read
48
Lesson 48

Columnar Storage and Vectorized Execution: Writing SQL That Aligns with How Analytical Databases Actually Process Your Queries

Most SQL practitioners write queries without understanding how columnar engines physically store and process data — and pay for it in two-minute queries that should take eight seconds. This lesson teaches you the internals of columnar storage, vectorized execution, and zone map pruning so you can write SQL that works with these mechanics rather than against them.

29 min read
49
Lesson 49

Understanding SQL Query Execution Plans: Reading EXPLAIN Output to Diagnose and Optimize Slow Queries

Stop guessing why your SQL queries are slow. Learn to read EXPLAIN and EXPLAIN ANALYZE output to diagnose performance problems, identify expensive operations, and apply targeted fixes that actually work.

19 min read
50
Lesson 50

Optimizing Window Function Performance: Partitioning Strategies, Frame Boundaries, and Index Alignment for Large Datasets

Window functions are powerful but can destroy query performance at scale. Learn how to design partition strategies, choose the right frame boundaries, and align indexes to eliminate sort spills and cut execution times by orders of magnitude.

25 min read
51
Lesson 51

Writing SQL for Slowly Changing Dimensions: Type 1, Type 2, and Type 6 Merge Patterns Using Window Functions and CTEs

Slowly Changing Dimensions are where data warehouse pipelines either earn trust or quietly corrupt history. This lesson teaches you production-grade SQL for Type 1 overwrites, Type 2 versioned history, and the hybrid Type 6 pattern — using MERGE, CTEs, and window functions to handle late-arriving data, phantom changes, and scale.

30 min read
52
Lesson 52

Reading and Interpreting SQL Query Execution Plans: A Beginner's Guide to EXPLAIN Output and Scan Types

Slow queries are frustrating — but the database is already telling you exactly what's wrong. Learn to read SQL execution plans from scratch: understand EXPLAIN output, decode scan types like Seq Scan and Index Scan, and spot performance problems before they hit production.

17 min read
53
Lesson 53

Writing SQL to Simulate LAG and LEAD Across Partition Boundaries: Handling Edge Cases Where Window Functions Return NULL

Window functions like LAG and LEAD stop at partition boundaries by design — but your business logic often doesn't. This lesson teaches five concrete SQL techniques for reaching across partition boundaries, with realistic e-commerce examples and performance guidance for each approach.

22 min read
54
Lesson 54

Writing SQL to Detect and Resolve Lock Contention: Using Query Plans, Wait Statistics, and Transaction Isolation to Diagnose and Fix Blocking in High-Concurrency Systems

Lock contention is one of the most damaging and misunderstood performance problems in production databases. This expert-level lesson walks you through the complete diagnostic and resolution workflow — from tracing blocking chains with recursive CTEs and system views, to reading execution plans for lock behavior, to choosing the right isolation level and implementing fixes that actually stick.

31 min read