MLDZMNportal6
    Updated 2022-12-23
    with tb1 as (
    select
    Label,
    ADDRESS as mints
    from solana.core.dim_labels
    where LABEL ilike '%portals%'),

    tb3 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)

    select
    MARKETPLACE,
    count(TX_ID) as sale_no,
    count(distinct PURCHASER) as buyer_no,
    sum(SALES_AMOUNT) as volume,
    sum(SALES_AMOUNT*price_token) as volume_usd,
    avg(SALES_AMOUNT) as average_volume_SOL,
    avg(SALES_AMOUNT*price_token) as average_volume,
    sale_no/buyer_no as average_buyer,
    buyer_no/count(distinct date_trunc(day, block_timestamp)) as average_buyer_day,
    volume_usd/count(distinct date_trunc(day, block_timestamp)) as average_volume_day
    from solana.core.fact_nft_sales x join tb3 y on x.BLOCK_TIMESTAMP::date=y.day
    left join tb1 a on x.mint=a.mints
    where SUCCEEDED='TRUE'
    and mint in (select mints from tb1)
    and SALES_AMOUNT>0
    and label!='portals.art'
    group by 1
    Run a query to Download Data