Percentiles
Question:
Each cat would like to know what weight percentile it is in. This requires casting to an integer
Return: name, weight, percent
Order by: weight Show Table Schema
Cats:
name | varchar |
breed | varchar |
weight | float |
color | varchar |
age | int |

Correct output but can you use 'cume_dist'?
×
Good work!
cume_dist() is similar to percent_rank(). The difference is the first entry in cume_dist is not 0. next question
Desired output:
name | weight | percent |
Tigger | 3.8 | 8 |
Molly | 4.2 | 17 |
Ashes | 4.5 | 25 |
Charlie | 4.8 | 33 |
Smudge | 4.9 | 42 |
Felix | 5.0 | 50 |
Puss | 5.1 | 58 |
Millie | 5.4 | 67 |
Alfie | 5.5 | 75 |
Misty | 5.7 | 83 |
Oscar | 6.1 | 100 |
Smokey | 6.1 | 100 |
select name, weight, cast(cume_dist() over (order by weight) * 100 as integer) as percent from cats order by weight