adambalaUntitled Query
Updated 2022-12-06Copy Reference Fork
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
›
⌄
WITH A AS
( select date_trunc('day', block_timestamp) as day,
case
when nft_collection = 'A.87ca73a41bb50ad5.Golazos' then 'LaLiga Golazos'
when nft_collection = 'A.0b2a3299cc857e29.TopShot' then 'NBA TopShot'
when nft_collection = 'A.e4cf4bdc1751c65d.AllDay' then 'NFL AllDay'
end as collection,
-- sum(price)*avg(price_usd) as USD,
-- avg(price)*avg(price_usd) as AVG_USD ,
sum(price) as VOLUME,
avg(price) as AVG_VOLUME,
count(distinct(tx_id)) as TRXS ,
count(distinct(buyer)) as BUYERS ,
count(distinct(SELLER)) as SELLERS ,
count(distinct(NFT_ID)) as NFT_IDS ,
row_number () over (partition by collection order by day) as DAYS
from flow.core.ez_nft_sales a
--join flow.core.fact_prices c on date_trunc('WEEK', A.block_timestamp) = date_trunc('WEEK', c.timestamp)
where tx_succeeded = 'TRUE'
and nft_collection in ('A.87ca73a41bb50ad5.Golazos', 'A.0b2a3299cc857e29.TopShot', 'A.e4cf4bdc1751c65d.AllDay')
and not currency = 'A.1654653399040a61.FlowToken' -- AND DAYS < 8
group by 1,2
)
, B AS ( SELECT A.* ,
sum(VOLUME) over (partition by collection order by DAYS) as CUM_VOLUME,
sum(TRXS) over (partition by collection order by DAYS) as CUM_TRXS,
sum(BUYERS) over (partition by collection order by DAYS) as CUM_BUYERS,
sum(SELLERS) over (partition by collection order by DAYS) as CUM_SELLERS,
sum(NFT_IDS) over (partition by collection order by DAYS) as CUM_NFT_IDS
FROM A WHERE DAYS <8 ),
C AS (select
date_trunc('day', block_timestamp) as day,
'FIFA+ Collect' as collection,
Run a query to Download Data