Afonso_Diaz2023-03-23 02:18 AM
    Updated 2023-03-22
    with t as (
    select
    hour::date as date,
    median(price) as price_usd
    from ethereum.core.fact_hourly_token_prices
    where symbol = 'WETH'
    group by 1
    )

    select case
    when price_usd * tx_fee < 1 then 'Less Than $1'
    when price_usd * tx_fee >= 1 and price_usd * tx_fee < 2 then 'Between $1 - $2'
    when price_usd * tx_fee >= 2 and price_usd * tx_fee < 3 then 'Between 2$ - $3'
    when price_usd * tx_fee >= 3 and price_usd * tx_fee < 4 then 'Between 3$ - $4'
    when price_usd * tx_fee >= 4 and price_usd * tx_fee < 5 then 'Between 4$ - $5'
    when price_usd * tx_fee >= 5 and price_usd * tx_fee < 6 then 'Between 5$ - $6'
    when price_usd * tx_fee >= 6 and price_usd * tx_fee < 7 then 'Between 6$ - $7'
    when price_usd * tx_fee >= 7 and price_usd * tx_fee < 8 then 'Between 7$ - $8'
    when price_usd * tx_fee >= 8 and price_usd * tx_fee < 9 then 'Between 8$ - $9'
    when price_usd * tx_fee >= 9 and price_usd * tx_fee < 10 then 'Between 9$ - $10'
    else 'More Than $10' end as type,
    count (distinct tx_hash) as votes,
    count (distinct voter) as voters
    from ethereum.aave.ez_votes
    join ethereum.core.fact_transactions a
    using (tx_hash)
    left join t on a.block_timestamp::date = t.date
    where block_timestamp >= current_date - interval '{{ months }} months'
    group by 1
    Run a query to Download Data