Query editor
-- Column order here is important! Will be split up laterWITHassets AS (SELECT *FROM (VALUES('eth', 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2)) AS t(asset, contract_address)),hist AS (SELECTa.asset,CAST(date_trunc('day', d.timestamp) AS date) AS day,max(d.price) AS priceFROM prices.day dJOIN assets aON d.contract_address = a.contract_addressWHERE d.blockchain = 'ethereum'AND d.timestamp < date_trunc('hour', now())AND d.timestamp >= date_trunc('hour', now()) - interval '{{hours}}' hour - interval '24' hourGROUP BY 1, 2),series AS (-- historicalSELECT * FROM histUNION ALL-- add "today" from prices.latest only if missing in histSELECTa.asset,CAST(date_trunc('day', now()) AS date) AS day,l.priceFROM prices.latest lJOIN assets aON l.contract_address = a.contract_addressWHERE l.blockchain = 'ethereum'AND NOT EXISTS (SELECT 1FROM hist hWHERE h.asset = a.assetAND h.day = CAST(date_trunc('day', now()) AS date))),prices AS (SELECTday,max(CASE WHEN asset = 'eth' THEN price END) AS price_ethFROM seriesGROUP BY 1)SELECTdate_trunc('hour', block_time) as hour,"to" AS address,ROW(