PIVOT and UNPIVOT in SQL Server: Turn Rows into Columns (and Back)
How to turn rows into columns in SQL: conditional aggregation that works everywhere, the SQL Server PIVOT operator, dynamic pivot, and two ways to unpivot (without losing NULLs).
How to turn rows into columns in SQL: conditional aggregation that works everywhere, the SQL Server PIVOT operator, dynamic pivot, and two ways to unpivot (without losing NULLs).
Group customers by the month they first bought and track how many come back. Build a retention triangle in SQL Server and MySQL, step by step.
Build a conversion funnel in SQL: count users per step, enforce step order, calculate drop-off with LAG, add a conversion window and compare mobile vs desktop.
Build an accounts receivable aging report in SQL Server step by step: open amount per invoice, days overdue, aging buckets per customer, totals, and common mistakes.
Learn how to use the SQL CASE expression for if/then/else logic: labels, conditional counts, custom sorting and more, with simple examples.