Query editor
-- we want rows where we get the most recent last trade and the current tradewith trades as (select token_id, block_time as start_time, LAG(block_time, 1, now()) OVER (PARTITION BY token_id ORDER BY block_time desc) as end_timefrom nft.tradeswhere lower(cast(nft_contract_address as varchar)) = lower('{{nft_contract}}') and evt_type = 'Trade')-- select token_id, start_time, end_time, extract(day from (end_time - start_time)) as days_held, 'NFT Sold' as event-- from trades-- where end_time != now()-- UNION-- select '-1' as token_id, date_trunc('day', start_time) as start_time, date_trunc('day', now()) as end_time, extract(day from (now() - start_time)) as days_held,-- 'Max Hold Time' as event-- from (select distinct start_time from trades)-- UNIONselect '-1' as token_id, date_trunc('day', end_time) as end_time, 'Holding Time' as event,avg(extract(day from (end_time - start_time))) as days_held, count(*) as NFTs_soldfrom tradeswhere end_time < now() - interval '2' daygroup by 1,2,3