Query editor
WITH first_appearance AS (SELECTdestination_wallet,MIN(date_trunc('week', date)) as first_weekFROM query_6754766GROUP BY destination_wallet),first_week_counts AS (SELECTfirst_week,COUNT(DISTINCT destination_wallet) as unique_not_repeatedFROM first_appearanceGROUP BY first_week),weekly_wallets AS (SELECTdate_trunc('week', date) as week,COUNT(DISTINCT destination_wallet) as unique_wallets_by_weekFROM query_6754766GROUP BY date_trunc('week', date)),weekly_txs AS (SELECTdate_trunc('week', date) as week,COUNT(*) as total_txsFROM query_6754766GROUP BY date_trunc('week', date))SELECTww.week as date,ww.unique_wallets_by_week,COALESCE(fwc.unique_not_repeated, 0) as unique_not_repeated,SUM(COALESCE(fwc.unique_not_repeated, 0)) OVER (ORDER BY ww.week) as accumulated_unique_wallets,wt.total_txs as weekly_total_txs,SUM(wt.total_txs) OVER (ORDER BY ww.week) as accumulated_total_txsFROM weekly_wallets wwLEFT JOIN first_week_counts fwc ON ww.week = fwc.first_weekLEFT JOIN weekly_txs wt ON ww.week = wt.weekORDER BY date