Ludwig_1989OPTI-Distribution of the number of NFTs held by Users
    Updated 2023-01-09
    with owner as (
    select * from (
    SELECT
    block_timestamp,
    tx_HASH,
    CONCAT(nft_address, '|', tokenid) as nft,
    buyer_address as purchaser,
    price_usd as amount,
    row_number() over(PARTITION BY nft ORDER BY block_timestamp desc) rn
    FROM optimism.core.ez_nft_sales
    where block_timestamp::date < CURRENT_DATE -1
    and price_usd > 0
    ) where rn = 1 order by block_timestamp desc
    )


    select
    case when bear_owned = 1 then '1 NFT'
    when bear_owned = 2 then '2 NFTs'
    when bear_owned = 3 then '3 NFTs'
    when bear_owned = 4 then '4 NFTs'
    else '>= 5 NFTs' end as owner_type,
    count(owner_type) as total
    from (
    select count(nft) as bear_owned,
    purchaser
    from owner
    group by purchaser
    ) group by owner_type
    Run a query to Download Data