DEV Community

Discussion on: 4 Ways to Calculate a Running Total With SQL

Collapse
 
seattledataguy profile image
SeattleDataGuy

Hello Helen!

Thank you for pointing that out. I forgot that gists don't work with github.

I changed the programming examples with markdown vs. github.

Cheers,
Ben

Collapse
 
helenanders26 profile image
Helen Anderson

Looking good!

If you'd like the code to be highlighted for SQL all you need to do is add the word sql immediately after your first set of back ticks.

select
    day
   , driver_id
   , sum(profit)
from
    (
   select
        t1.day
      , t2.day      
      , t1.driver_id
      , t2.profit
    from f_daily_rides t1
        join f_daily_rides t2
        on driver_id =driver_id
            and t1.month = t2.month
            and t1.year = t2.year
            and t1.day >=t2.day
) t3
group by day
Thread Thread
 
seattledataguy profile image
SeattleDataGuy

Oh! I didn't actually know that.

I went back and updated some other posts too that have python and json.

Thanks for all your help!

Thread Thread
 
helenanders26 profile image
Helen Anderson

No worries Ben, keep the awesome SQL content coming :)