From: Rosa Delgado, chief executive
Deliverable: one query returning one row with every first-half KPI
"For Thursday's leadership meeting I want the first half of 2025 on one line: revenue, orders, average order, customers, the share of customers who ordered more than once, the share of orders returned, how long we take to ship, our best category, and how much the second quarter grew on the first."
Rules: orders from January 1 to June 30, 2025, without the cancelled ones. Repeat rate is customers with two or more orders as a share of customers. Return rate is returned orders as a share of orders. Growth is Q2 revenue against Q1.
How this works: each step starts from your previous query and adds one column, in the order above.
A KPI pack is a set of headline numbers built on one consistent set of rules. Putting them in one query guarantees that consistency: every number comes from the same filtered orders.
The query starts with a CTE that applies the brief's rules once, then each KPI is a column over it: plain aggregates, conditional ones with FILTER, and a few scalar subqueries over helper CTEs for numbers that need their own grouping (repeat customers, the best category).