zakkisyedNFT Paper Hands on Ethereum
Updated 2021-11-05
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
›
⌄
WITH
nft_events_dedup as (
SELECT
*,
row_number() OVER (PARTITION BY TX_ID ORDER BY PRICE_USD) as rn
FROM ethereum.nft_events
),
nft_pnl_events AS (
SELECT
*,
lag(price) OVER (PARTITION BY event_platform, contract_address, token_id, tx_currency ORDER BY block_timestamp) as prev_price,
lag(price_usd) OVER (PARTITION BY event_platform, contract_address, token_id, tx_currency ORDER BY block_timestamp) as prev_price_usd,
price_usd - lag(price_usd) OVER (PARTITION BY event_platform, contract_address, token_id, tx_currency ORDER BY block_timestamp) as pnl
FROM
nft_events_dedup
where
rn = 1
AND event_type = 'sale'
)
SELECT
*
FROM nft_pnl_events
WHERE
block_timestamp >= DATEADD(month, -2, CURRENT_TIMESTAMP())
ORDER BY pnl
LIMIT 100
Run a query to Download Data