Median Order Value (No MEDIAN Function)

medium
Unit 2 · Window Functions I0/3 to milestone

Averages are skewed by one huge order. The median is more robust, but SQLite (like many databases) has no MEDIAN function.

Return a single row with one column, median_order_value: the median of all order totals. With an even number of orders, it's the average of the two middle values.

Schema

customers(id, name, country, signup_date)
orders(id, customer_id, order_date, total)
#window-functions#statistics#interview1 visible + 2 hidden tests
query.sql · SQLite
Loading editor…
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
Median Order Value (No MEDIAN Function) · TechGradify