Query editor
WITH earnings_calc AS (SELECTdate_trunc('hour', rf.evt_block_time) as request_hour,-- Double parse: request содержит JSON, offer внутри него тоже JSONCAST(json_extract_scalar(json_extract_scalar(rs.request, '$.offer'),'$.maxPrice') AS DOUBLE) / 1e18 as price_ethFROM boundless_base.BoundlessMarket_evt_RequestFulfilled rfJOIN boundless_base.BoundlessMarket_evt_RequestSubmitted rsON rf.requestId = rs.requestId),hourly_stats AS (SELECTrequest_hour,SUM(price_eth) as total_eth,COUNT(*) as proofs_countFROM earnings_calcWHERE price_eth IS NOT NULLGROUP BY request_hour)SELECTrequest_hour,total_eth as hourly_earnings_eth,SUM(total_eth) OVER (ORDER BY request_hour) as cumulative_earnings_ethFROM hourly_statsORDER BY request_hour DESC