Query editor
WITHactive_traders AS (SELECT DISTINCTtaker AS traderFROMdex.tradesWHEREblockchain = '{{chain}}'AND block_month = date_trunc('month', now())AND block_time >= now() - interval '{{days since last active}}' dayand taker not in (selectaddressfrom{{chain}}.creation_traces)),new_tokens AS (SELECTaddress AS tokenFROM{{chain}}.creation_tracesWHEREblock_time >= now() - interval '{{days since token created}}' day),bought AS (SELECTtaker AS trader,token_bought_address AS token,token_bought_amount AS bought_amount,token_sold_amount AS invest_amount,block_time,amount_usd,SUM(token_bought_amount) OVER (PARTITION BYtaker,token_bought_addressORDER BYblock_time) AS cumulative_boughtFROMdex.tradesWHEREblockchain = '{{chain}}'AND block_month >= date_trunc('day',now() - interval '{{days since token created}}' day)AND token_sold_address = (selectprice_addressfromtokens.nativewherechain = '{{chain}}')AND taker IN (SELECTtraderFROM