PS0G1Top 5 collections with the most gained value 2022
    Updated 2023-01-06
    --SQL by https://app.flipsidecrypto.com/velocity/queries/d2924c17-9b8a-449a-8f8a-27d1fe5cab27
    with first_sale as ( select min(trunc(block_timestamp,'month')) as day,
    label,
    nft_address
    from ethereum.core.ez_nft_sales a join ethereum.core.dim_labels b on a.nft_address = b.address
    where block_timestamp >= '2022-01-01'
    and block_timestamp < '2023-01-01'
    and price_usd > 0
    group by 2,3)
    ,
    last_sale as ( select max(trunc(block_timestamp,'month')) as day,
    label,
    nft_address
    from ethereum.core.ez_nft_sales a join ethereum.core.dim_labels b on a.nft_address = b.address
    where block_timestamp >= '2022-01-01'
    and block_timestamp < '2023-01-01'
    and price_usd > 0
    group by 2,3)
    ,
    first_price as ( select label,
    count(DISTINCT tx_hash) as count_tx,
    median(price_usd) as f_price
    from ethereum.core.ez_nft_sales a join first_sale b on a.nft_address = b.nft_address
    where day = trunc(block_timestamp,'month')
    and price_usd > 0
    group by 1)
    ,
    second_price as ( select label,
    count(DISTINCT tx_hash) as count_tx,
    median(price_usd) as l_price
    from ethereum.core.ez_nft_sales a join last_sale b on a.nft_address = b.nft_address
    where day = trunc(block_timestamp,'month')
    and price_usd > 0
    group by 1)

    select a.label,
    Run a query to Download Data