zakkisyedNFT Paper Hands on Ethereum
    Updated 2021-11-05
    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