Each Order Compared with the Customer's Average

medium
Unit 17 · Window Functions X0/2 to milestone

Return each order's id, customer_id, total, customer_avg (that customer's average order, rounded to 2 decimals) and vs_avg: 'above', 'below' or 'equal' comparing the order to the unrounded average. Sort by customer_id, then id.

Pro problem

Unlock this and every premium problem across all tracks — plus hidden-test grading, advanced AI engineering modules and new content every week.

Start 7-day free trial
query.sql · SQLite
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
Each Order Compared with the Customer's Average · TechGradify