Query editor
WITH first_appearance AS (SELECTmaker,MIN(date_trunc('day', (date_trunc('week', evt_block_time + interval '3' day)) - interval '3' day)) AS first_active_weekFROM probable_v1_bnb.ctfexchange_evt_orderfilledGROUP BY maker),weekly_stats AS (SELECT-- Custom week truncation for event timedate_trunc('day', (date_trunc('week', evt_block_time + interval '3' day)) - interval '3' day) AS week,COUNT(DISTINCT evt_tx_hash) AS unique_ctf_txns,COUNT(DISTINCT maker) AS unique_ctf_wau,ROUND(COUNT(DISTINCT evt_tx_hash)*1.0 / NULLIF(COUNT(DISTINCT maker), 0), 2) AS txn_user_ratio,COUNT(DISTINCT evt_tx_from) AS unique_tx_from,COUNT(maker) AS ctf_wauFROM probable_v1_bnb.ctfexchange_evt_orderfilledGROUP BY 1),weekly_new_users AS (SELECTfirst_active_week AS week,COUNT(DISTINCT maker) AS new_wauFROM first_appearanceGROUP BY first_active_week)SELECTws.week,ws.unique_ctf_txns,ws.unique_ctf_wau,ws.txn_user_ratio,ws.unique_tx_from,ws.ctf_wau,COALESCE(wnu.new_wau, 0) AS new_wauFROM weekly_stats wsLEFT JOIN weekly_new_users wnu ON ws.week = wnu.weekORDER BY ws.week DESC;