Table name is dogs. The table includes columns 1. name varchar 2. breed varchar 3. weight float 4. color varchar 5. age int
The dogs will enter an elevator one by one. We need to know what the running total weight is. The dogs must be ordered by name as well.
Possible solution:
It’s a typical running total question.
with ordered as ( select name, weight from dogs order by name)
select name, SUM (weight) OVER (ORDER BY name) AS running_total_weight from ordered group by name