Query editor
with buys as(select buyer, price amount, evt_block_time, decode('0000000000000000000000000000000000000000', 'hex') as price_tokenfrom rarible."TokenSale_evt_Buy"union allselect buyer, price amount, evt_block_time, decode('0000000000000000000000000000000000000000', 'hex') as price_tokenfrom rarible_v1."ERC721Sale_v1_evt_Buy"union allselect buyer, price * value as amount, evt_block_time, decode('0000000000000000000000000000000000000000', 'hex') as price_tokenfrom rarible_v1."ERC1155Sale_v1_evt_Buy"union allselect buyer, price amount, evt_block_time, decode('0000000000000000000000000000000000000000', 'hex') as price_tokenfrom rarible_v1."ERC721Sale_v2_evt_Buy"union allselect buyer, price * value as amount, evt_block_time, decode('0000000000000000000000000000000000000000', 'hex') as price_tokenfrom rarible_v1."ERC1155Sale_v2_evt_Buy"union allselect buyer, "buyValue" * amount / "sellValue" as amount, evt_block_time, "buyToken" as price_tokenfrom rarible."ExchangeV1_evt_Buy" where "buyTokenId" = 0 --buyunion allselect owner as buyer, amount, evt_block_time, "sellToken" as price_tokenfrom rarible."ExchangeV1_evt_Buy" where "sellTokenId" = 0 --bid)select date_trunc('month', evt_block_time) as d, sum(amount * p.price / 10^p.decimals) as sum_value_1mnthfrom buysINNER JOIN prices.usd p ON p.minute = date_trunc('minute', evt_block_time) ANDp.contract_address = CASE price_tokenWHEN '\x0000000000000000000000000000000000000000' THEN '\xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'ELSE price_tokenENDwhere evt_block_time > now() - interval '12 month'group by date_trunc('month', evt_block_time);