Query editor
with users_details as (select block_time, addressfrom bitcoin.inputsunion allselect block_time, addressfrom bitcoin.outputs),users_initial_transaction as (select address,min(date_trunc('day', block_time)) as min_block_datefrom users_detailsgroup by 1),new_users_daily as (select min_block_date as block_date,count(address) as new_users_countfrom users_initial_transactiongroup by 1),active_users_daily as (select date_trunc('day', block_time) as block_date,count(distinct address) as active_users_countfrom users_detailsgroup by 1)select u.block_date,active_users_count,avg(active_users_count) over (order by u.block_date rows between 29 preceding and current row) as DAU_30ma,avg(active_users_count) over (order by u.block_date rows between 364 preceding and current row) as DAU_365ma,coalesce(new_users_count, 0) as new_users_count,active_users_count - coalesce(new_users_count, 0) as existing_users_count,(cast(coalesce(new_users_count, 0) as double)/active_users_count)*100 as new_users_percentage,100-(cast(coalesce(new_users_count, 0) as double)/active_users_count)*100 as existing_users_percentagefrom active_users_daily uleft join new_users_daily n on u.block_date = n.block_datewhere u.block_date between cast(date('2015-07-01')as timestamp) and date_trunc('day',now()-interval '1' day)order by u.block_date