Query editor
WITHethRewards AS (select*,'ethereum' AS blockchainfromerc20_ethereum.evt_transferwhere"to" = 0xA02782CE1bF85f56f8cC7C0E66e61299Ac75c86fAND evt_block_time >= TIMESTAMP '2022-05-01'),polygonRewards AS (select*,'polygon' AS blockchainfromerc20_polygon.evt_transferwhere"to" = 0x9AC2bA4bf7FaCB0bbB33447e5fF8f8D63B71dDC1AND evt_block_time >= TIMESTAMP '2022-05-01'),bnbRewards AS (select*,'bnb' AS blockchainfromerc20_bnb.evt_transferwhere"to" = 0x753f0F9BA003DDA95eb9284533Cf5B0F19E441dcAND evt_block_time >= TIMESTAMP '2022-05-01'),combined AS (select*fromethRewardsUNION ALLSELECT*FROMpolygonRewardsUNION ALLSELECT*FrombnbRewards)SELECTdate_trunc('month', evt_block_time) AS block_month,SUM((CAST(value AS DECIMAL(38, 0)) / POW(10, t.decimals)) * COALESCE(p.price, 0)) AS total_usd_value,SUM(CASEWHEN c.blockchain = 'ethereum' THEN (CAST(value AS DECIMAL(38, 0)) / POW(10, t.decimals)) * COALESCE(p.price, 0)ELSE 0