with prices as (
select
date(timestamp) as day,
avg(price_usd) as priceusd
from
flow.core.fact_prices
where
token='Flow'
group by
1
), daily_stat as (
select
round(log(2, PRICE*priceusd)) as pri
from
flow.core.ez_nft_sales s join prices p on date(block_timestamp)=p.day
where
nft_collection = 'A.e4cf4bdc1751c65d.AllDay' and TX_SUCCEEDED
)
select
concat(lpad(pow(2,pri),7,'0'),pri,' USD') as p,
count(*) as cnt
from
daily_stat
group by pri
order by p asc