Correct Running Total
Question:
The cats must be ordered by weight descending and will enter an elevator one by one. We would like to know what the running total weight is.
If two cats have the same weight they must enter separately
Return: name, running total weight
Order by: weight desc Show Table Schema
Cats:
name | varchar |
breed | varchar |
weight | float |
color | varchar |
age | int |

Correct output but can you use 'unbounded preceding'?
×
Good work!
Use Unbounded Preceding to make sure you don't include extra rows if 2 rows evaluate to the same thing next question
Desired output:
name | running_total_weight |
Smokey | 6.1 |
Oscar | 12.2 |
Misty | 17.9 |
Alfie | 23.4 |
Millie | 28.8 |
Puss | 33.9 |
Felix | 38.9 |
Smudge | 43.8 |
Charlie | 48.6 |
Ashes | 53.1 |
Molly | 57.3 |
Tigger | 61.1 |
select name, sum(weight) over (order by weight DESC ROWS between unbounded preceding and current row) as running_total_weight from cats order by running_total_weight