MLDZMNmadd4
    Updated 2023-06-03
    with time as (
    select
    case
    when '{{Period}}' = 'Last 24 Hours' then 1
    when '{{Period}}' = 'Last 7 Days' then 7
    when '{{Period}}' = 'Last 30 Days' then 30
    when '{{Period}}' = 'All Time' then 500
    else 30
    end as time_gp
    ),

    tb2 as (select
    RECORDED_HOUR::date as day,
    avg(close) as price_token
    from solana.core.fact_token_prices_hourly where SYMBOL='SOL'
    group by 1),

    whales as (SELECT
    distinct purchaser as whale,
    sum(SALES_AMOUNT*price_token) as total_purchase

    from solana.core.fact_nft_sales s
    left outer join solana.core.dim_labels b on s.mint=b.address
    join tb2 y on s.BLOCK_TIMESTAMP::date=y.day
    where SUCCEEDED='TRUE'
    group by 1 having total_purchase>50000
    ),

    tb3 as (select
    LABEL as NFTs,
    count(distinct TX_ID) as sale_no,
    count(distinct PURCHASER) as buyer_no,
    count (distinct s.MINT) as no_NFTs,
    sum(SALES_AMOUNT) as volume,
    sum(SALES_AMOUNT*price_token) as volume_usd
    from solana.core.fact_nft_sales s
    Run a query to Download Data