Query editor
WITH query1 AS (SELECTday,token_balanceFROM query_8224244), query2 AS (selectday,address,sum(token_balance) as bd_tvlfromquery_8224111where address in (0x7d837bf114785642d225d1101145ddb8af4ba438, 0xc65a05737d31e0f42c0806c739f3c88dd009c05f, 0x4eb3b6970fd358d34195b5d40e4eb64e0e3c0b6a, 0x6bd55dd953507641c84a03956760f83d29d65726, 0x25afbb09d9804482ed8e24295be4a12704fe93ea)group by 1, 2)SELECTq1.day AS date,sum(q1.token_balance) as token_balance,sum((case when address = 0x7d837bf114785642d225d1101145ddb8af4ba438 then q2.bd_tvl else 0 end)/q1.token_balance) as weth,sum((case when address = 0xc65a05737d31e0f42c0806c739f3c88dd009c05f then q2.bd_tvl else 0 end)/q1.token_balance) as wsteth,sum((case when address = 0x4eb3b6970fd358d34195b5d40e4eb64e0e3c0b6a then q2.bd_tvl else 0 end)/q1.token_balance) as reth,sum((case when address = 0x6bd55dd953507641c84a03956760f83d29d65726 then q2.bd_tvl else 0 end)/q1.token_balance) as cbbtc,sum((case when address = 0x25afbb09d9804482ed8e24295be4a12704fe93ea then q2.bd_tvl else 0 end)/q1.token_balance) as cbeth,sum(q2.bd_tvl) as bd_tvl,sum(q2.bd_tvl / q1.token_balance) AS bd_pct_spFROM query1 AS q1JOIN query2 AS q2ON q1.day = q2.dayGROUP BY 1ORDER BY q1.day DESC