Abolfazl_771025user categorize by volume of action (staking)
    Updated 2022-12-31
    with luna_price as(select
    date_trunc('day',RECORDED_HOUR) as date,
    avg(CLOSE) as price
    from crosschain.core.fact_hourly_prices
    where ID = 'terra-luna-2'
    group by 1
    ), main as(select
    DISTINCT DELEGATOR_ADDRESS as user,
    action as "Action",
    count(TX_ID) as "action count",
    sum(amount) as "action volume"
    from terra.core.ez_staking
    where TX_SUCCEEDED = TRUE
    group by 1,2)
    select
    case
    when "action volume" < 100 then 'less than 100 USD'
    when "action volume" between 100 and 499.99 then '100 - 500 USD'
    when "action volume" between 500 and 999.99 then '500 - 1 K USD'
    when "action volume" between 10000 and 2499.99 then '1 K - 2.5 K USD'
    when "action volume" between 2500 and 4999.99 then '2.5 K - 5 K USD'
    when "action volume" between 5000 and 9999.99 then '5 K - 10 K USD'
    when "action volume" between 10000 and 19999.99 then '10 K - 20 K USD'
    when "action volume" between 20000 and 49999.99 then '20 K - 50 K USD'
    when "action volume" between 50000 and 999999.99 then '50 K - 100 K USD'
    else 'more than 100 K USD'
    end as "action volume",
    "Action",
    count(user) as "count of users"
    from main
    group by 1,2
    Run a query to Download Data