Orders in the Top Quartile

medium
Unit 15 · Window Functions VIII0/2 to milestone

Split all orders into four groups by total (highest first) with NTILE(4), ordering ties by id. Return the id and total of orders in the top group, sorted by total descending, then id.

Schema

customers(id, name, country, signup_date)
orders(id, customer_id, order_date, total)
#window-functions#ntile1 visible + 1 hidden tests
query.sql · SQLite
Loading editor…
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
Orders in the Top Quartile · TechGradify