Percent Rank of Each Order

medium
Checkpoint challenge
Solve this to show you know the material and jump straight to Unit 16. Everything before it counts as cleared.

Return every order's id, total and pct_rank: its PERCENT_RANK() by total ascending, rounded to 3 decimals. Sort by total, then id.

PERCENT_RANK is (rank - 1) / (rows - 1), so the smallest order gets 0 and the largest gets 1.

Schema

customers(id, name, country, signup_date)
orders(id, customer_id, order_date, total)
#window-functions#ranking1 visible + 1 hidden tests
query.sql · SQLite
Loading editor…
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
Percent Rank of Each Order · TechGradify