select
date_trunc('week', block_timestamp) as "Day",
validator_label as "Validator name",
count(distinct tx_id) as "tx count",
count(distinct delegator_address) as "Unique wallet",
sum(amount) as "Volume",
avg(amount) as "AVG volume",
row_number() over (partition by "Day" order by "Volume" desc) as "Rank"
from terra.core.ez_staking
where tx_succeeded = 'TRUE' and action = 'Delegate' and validator_label is not null
group by 1, 2 qualify "Rank" <= 10
order by 1