Eman-RazClassification of Users Based on the Number of NFTs Purchased
    Updated 2023-04-19
    with table2 as (with table1 as (with tab1 as (select date_trunc('day',block_timestamp) as day, tx_hash,
    nft_address, project_name, nft_from_address, nft_to_address, tokenid
    from ethereum.core.ez_nft_transfers),
    tab2 as (select date_trunc('day',block_timestamp) as day, tx_hash, from_address, tx_fee, eth_value
    from ethereum.core.fact_transactions
    where to_address='0x74312363e45dcaba76c59ec49a7aa8a65a67eed3' --X2Y2: Exchange
    and eth_value<>0)
    select tab1.day as date, tab1.tx_hash as tx_id, nft_address, project_name, nft_from_address as nft_seller,
    from_address as nft_purchaser, tokenid, tx_fee, eth_value
    from tab1 left join tab2 on tab1.tx_hash=tab2.tx_hash and tab1.nft_to_address=tab2.from_address
    order by 1)
    select nft_purchaser, count(distinct tx_id) as nft_count, case
    when nft_count=1 then 'n=1'
    when nft_count=2 then 'n=2'
    when nft_count=3 then 'n=3'
    when nft_count=4 then 'n=4'
    when nft_count=5 then 'n=5'
    when nft_count>5 and nft_count<=10 then '5<n<=10'
    when nft_count>10 and nft_count<=20 then '10<n<=20'
    when nft_count>20 and nft_count<=30 then '20<n<=30'
    when nft_count>30 and nft_count<=40 then '30<n<=40'
    when nft_count>40 and nft_count<=50 then '40<n<=50'
    when nft_count>50 and nft_count<=100 then '50<n<=100'
    when nft_count>100 then 'n>100'
    end as group_
    from table1
    where nft_purchaser is not null
    group by 1)
    select group_,count(nft_purchaser) as user_count
    from table2
    group by 1
    order by 2


    Run a query to Download Data