MLDZMNfNFT3
    Updated 2022-09-18
    with price AS (
    select
    BLOCK_TIMESTAMP::date as day1,
    (sum(SWAP_TO_AMOUNT)/sum(SWAP_FROM_AMOUNT)) as price_usd
    from solana.core.fact_swaps
    where SWAP_FROM_MINT = 'So11111111111111111111111111111111111111112'
    and SWAP_TO_MINT = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'
    and day1>='2022-05-01'
    group by 1)
    SELECT
    CASE WHEN SALES_AMOUNT*price_usd <= 200 THEN 'a.below 100'
    WHEN SALES_AMOUNT*price_usd > 100 and SALES_AMOUNT*price_usd <=500 THEN 'b.100-500'
    WHEN SALES_AMOUNT*price_usd > 500 and SALES_AMOUNT*price_usd <=2000 THEN 'c.500-2000'
    WHEN SALES_AMOUNT*price_usd > 2000 and SALES_AMOUNT*price_usd <=10000 THEN 'd.2000-10000'
    WHEN SALES_AMOUNT*price_usd > 10000 THEN 'f.above 10000'
    END as buckets,
    count(distinct PURCHASER) as purchasers,
    COUNT (tx_id) as total_sales
    FROM solana.fact_nft_sales inner join price on price.day1=date_trunc('day',BLOCK_TIMESTAMP)
    where BLOCK_TIMESTAMP>='2022-05-01'
    GROUP BY 1 having buckets is not null
    Run a query to Download Data