Query editor
WITH all_chains AS (SELECT-value AS amount,"from" AS user,contract_address AS token,evt_block_timeFROM eigenpie_ethereum.MLRT_evt_TransferUNION ALLSELECTvalue AS amount,"to" AS user,contract_address AS token,evt_block_timeFROM eigenpie_ethereum.MLRT_evt_Transfer),cumulative_balances AS (SELECTuser,token,evt_block_time,SUM(amount) OVER (PARTITION BY user, token ORDER BY evt_block_time) AS balanceFROM all_chains),holding_durations_with_lead AS (SELECTuser,token,evt_block_time AS start_time,LEAD(evt_block_time) OVER (PARTITION BY user, token ORDER BY evt_block_time) AS end_time,balanceFROM cumulative_balances),holding_durations AS (SELECTuser,token,GREATEST(start_time, TRY_CAST('{{start_time}}' AS TIMESTAMP)) AS start_time,LEAST(COALESCE(end_time, TRY_CAST('{{end_time}}' AS TIMESTAMP)), TRY_CAST('{{end_time}}' AS TIMESTAMP)) AS end_time,balanceFROM holding_durations_with_leadWHEREstart_time < TRY_CAST('{{end_time}}' AS TIMESTAMP)AND COALESCE(end_time, TRY_CAST('{{end_time}}' AS TIMESTAMP)) > TRY_CAST('{{start_time}}' AS TIMESTAMP)),hourly_points AS (SELECTuser,token,date_diff('hour', start_time, end_time) AS hours_held,balanceFROM holding_durationsWHERE balance > 0 AND start_time < end_time)SELECTuser,token,casewhen symbol is NULL and token=0x879054273cb2dad631980fa4efe6d25eefe08aa4 then 'msfrxETH'when symbol is NULL and token=0x8a053350ca5f9352a16ded26ab333e2d251dad7c then 'mmETH'when symbol is NULL and token=0x9a1722b1f4a1bb2f271211ade8e851afc54f77e5 then 'mETHx'