with tab1 as (
select
tx_from,
min(BLOCK_TIMESTAMP) as min_time
from osmosis.core.fact_transactions
GROUP by 1
)
select
date_trunc('week', min_time) as week,
PROJECT_NAME,
count(*)
FROM osmosis.core.fact_swaps
LEFT OUTER JOIN tab1
ON trader = tx_from
AND min_time = BLOCK_TIMESTAMP
LEFT outer JOIN osmosis.core.dim_tokens
ON to_currency = address
WHERE NOT tx_from is NULL
GROUP BY 1,2