winnie-fsSolana Rolling Avg Sales Volume copy
Updated 2024-09-04
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
›
⌄
-- forked from kellen / Solana Rolling Avg Sales Volume @ https://flipsidecrypto.xyz/kellen/q/xevV9x-3WMUT/solana-rolling-avg-sales-volume
with p as (
select hour::date as date
, avg(price) as avg_price
from crosschain.price.ez_prices_hourly
where hour >= '2021-01-01'
and token_address in (
'So11111111111111111111111111111111111111112'
)
group by 1
), t0 as (
select date_trunc('day', BLOCK_TIMESTAMP) as date
, count (distinct tx_id) as n_sales
, count (distinct purchaser) as n_buyers
, count (distinct seller) as n_sellers
, count (distinct mint) as n_mints
, sum(sales_amount) as volume
, avg(sales_amount) as avg_price
, median(sales_amount) as median_price
, count(distinct block_timestamp::date) as n_days
, sum(sales_amount * avg_price) as volume_usd
from solana.nft.fact_nft_sales s
join p
on p.date = s.block_timestamp::date
where block_timestamp::date < current_date
and succeeded = 'TRUE'
and sales_amount < 1000
group by 1
), t1 as (
select *
, avg(volume) OVER (
order by date
rows between 29 preceding and current row
) AS rolling_avg_30_days
QueryRunArchived: QueryRun has been archived