Query editor
WITH interest as(SELECTdate_trunc('day', block_time - INTERVAL '7 HOURS') AS day,sum(interest_accumulated_usd) as accrued,token_symbolFROM compound."view_accrue_interest"WHERE block_time - INTERVAL '7 HOURS' >= TO_TIMESTAMP('2020-06-15 11:20:00','YYYY-MM-DD HH:MI:SS')GROUP BY day, token_symbolORDER BY 1 desc),total_interest as(SELECTday,sum(accrued) as sum_accruedFROM interestGROUP BY day),percents as(SELECTinterest.day as day,accrued / sum_accrued as percent_accrued,token_symbolFROM interestLEFT JOIN total_interest ON interest.day = total_interest.dayGROUP BY interest.day, token_symbol, accrued, sum_accruedORDER by day)SELECTday as day,token_symbol as "Token Symbol",percent_accrued * 2880 as "COMP Earned Per Day",sum(percent_accrued * 2880) over (partition by token_symbol order by day) as "Cumulative COMP Earned"FROM percentsGROUP BY day, token_symbol, percent_accruedORDER BY day