--credit : 0xHaM☰d
with active_user as (
select
date_trunc('week', block_timestamp)::date as date,
tx_from as active_users,
count(distinct block_timestamp::date) as dt_cnt
from osmosis.core.fact_transactions
group by 1, 2
having dt_cnt >= 4
)
select
COUNT(DISTINCT active_users) as active_user_cnt,
COUNT(DISTINCT tx_id) as tx_cnt
from active_user a join osmosis.core.fact_transactions b on a.active_users = b.tx_from