Query editor
with user_metrics AS (selectcreations.address,date_trunc('day', block_time) as date,min(date_trunc('day', creation_time)) as creation_date,count(tx_hash) as n_transfers,count(case when direction = 'in' then tx_hash end) as n_in_transfers,count(case when direction = 'out' then tx_hash end) as n_out_transfers,count(distinct tx_hash) as n_transactions,sum(case when direction = 'in' then amount_usd end) as inflows_usd,sum(case when direction = 'in' then amount_usd_norm end) as inflows_usd_norm,sum(case when direction = 'out' then amount_usd end) as outflows_usd,sum(case when direction = 'out' then amount_usd_norm end) as outflows_usd_normfrom query_3108206 creations -- safe creationsleft join query_3099888 transfers -- safe transferson creations.address = transfers.addresswhere true-- and creations.address in (0xBfe169af35c48061FB4CD03c116Ab5c8d8D18AD4, 0x3b74e96b6d91546763dc63e40e7ea006afd48c2c)group by 1, 2)-- counts all created safes in the denominator (even the ones without any transfers)selectdate_trunc('day', creation_date) as creation_date,count(distinct address) as n_created_safes,cast(count(distinct case when EXTRACT(DAY FROM (date - creation_date)) = 0 and n_transfers > 0 then address end) as double) / count(distinct address) as period_1_perc,cast(count(distinct case when EXTRACT(DAY FROM (date - creation_date)) = 1 and n_transfers > 0 then address end) as double) / count(distinct address) as period_2_perc,cast(count(distinct case when EXTRACT(DAY FROM (date - creation_date)) = 2 and n_transfers > 0 then address end) as double) / count(distinct address) as period_3_perc,cast(count(distinct case when EXTRACT(DAY FROM (date - creation_date)) = 3 and n_transfers > 0 then address end) as double) / count(distinct address) as period_4_perc,cast(count(distinct case when EXTRACT(DAY FROM (date - creation_date)) = 4 and n_transfers > 0 then address end) as double) / count(distinct address) as period_5_perc,cast(count(distinct case when EXTRACT(DAY FROM (date - creation_date)) = 5 and n_transfers > 0 then address end) as double) / count(distinct address) as period_6_perc,cast(count(distinct case when EXTRACT(DAY FROM (date - creation_date)) = 6 and n_transfers > 0 then address end) as double) / count(distinct address) as period_7_perc,cast(count(distinct case when EXTRACT(DAY FROM (date - creation_date)) = 7 and n_transfers > 0 then address end) as double) / count(distinct address) as period_8_perc,cast(count(distinct case when EXTRACT(DAY FROM (date - creation_date)) = 8 and n_transfers > 0 then address end) as double) / count(distinct address) as period_9_perc,cast(count(distinct case when EXTRACT(DAY FROM (date - creation_date)) = 9 and n_transfers > 0 then address end) as double) / count(distinct address) as period_10_perc,cast(count(distinct case when EXTRACT(DAY FROM (date - creation_date)) = 10 and n_transfers > 0 then address end) as double) / count(distinct address) as period_11_perc,cast(count(distinct case when EXTRACT(DAY FROM (date - creation_date)) = 11 and n_transfers > 0 then address end) as double) / count(distinct address) as period_12_perc,cast(count(distinct case when EXTRACT(DAY FROM (date - creation_date)) = 12 and n_transfers > 0 then address end) as double) / count(distinct address) as period_13_perc,cast(count(distinct case when EXTRACT(DAY FROM (date - creation_date)) = 13 and n_transfers > 0 then address end) as double) / count(distinct address) as period_14_percfrom user_metricswhere creation_date >= (date(current_date) - INTERVAL '14' day)group by 1 order by 1