Query editor
withbase as (select *from "query_6912676(frequency='day',timeframe='last 3 months')")-- Anchor the "now" reference date PER BLOCKCHAIN, not globally.-- Chains have different data freshness (e.g. Solana/Jupiter Lend lags EVM by ~1 day),-- so a single global max_day leaves the laggard chain with no "now" row and-- produces spurious -100% changes., latest as (selectblockchain, max(from_ts) as max_dayfrom basegroup by 1), snapshots as (selectb.user_address, b.user_name, b.user_type, b.blockchain, casewhen b.from_ts = l.max_day then 'now'when b.from_ts = l.max_day - interval '1' day then '1d_ago'when b.from_ts = l.max_day - interval '7' day then '7d_ago'when b.from_ts = l.max_day - interval '30' day then '30d_ago'end as snapshot, b.market_size, b.active_loans, b.tvlfrom base as bjoin latest as lon b.blockchain = l.blockchainwhere b.from_ts in (l.max_day, l.max_day - interval '1' day, l.max_day - interval '7' day, l.max_day - interval '30' day)), pivoted as (selectuser_address, user_name, user_type, blockchain, max(case when snapshot = 'now' then market_size end) as market_size_now, max(case when snapshot = '1d_ago' then market_size end) as market_size_1d_ago, max(case when snapshot = '7d_ago' then market_size end) as market_size_7d_ago, max(case when snapshot = '30d_ago' then market_size end) as market_size_30d_ago, max(case when snapshot = 'now' then active_loans end) as active_loans_now, max(case when snapshot = '1d_ago' then active_loans end) as active_loans_1d_ago, max(case when snapshot = '7d_ago' then active_loans end) as active_loans_7d_ago, max(case when snapshot = '30d_ago' then active_loans end) as active_loans_30d_ago, max(case when snapshot = 'now' then tvl end) as tvl_now