Conditional Aggregation with CASE
Medium
case-when
Spotify
Coinbase
Netflix
Write a query using CASE inside aggregate functions to create a pivot-like summary. Count the number of orders in each status ('pending', 'shipped', 'delivered') per customer. Return customer_id, pending_count, shipped_count, and delivered_count, ordered by customer_id.
Expected Output: Per-customer counts of each order status.
Tables
Hints (3 available)
SQL Editor
Output
Click "Run" to see results...