Updated 2022-10-10

    -- Credit: https://app.flipsidecrypto.com/velocity/queries/4fb4a340-7a32-4b5a-b110-d20ccf1aa2e3

    with sportnfts as (
    select * from solana.core.dim_labels
    where address_name in ('Hockey Heroes','Collectorz Club: The Collectorz','collectorz club gen1','The Suites','Laidback Lions','Sports Rewind')),

    SOLPricet as (
    select block_timestamp::date as day,
    avg (swap_to_amount/swap_from_amount) as SOLprice
    from solana.fact_swaps
    where swap_from_mint = 'So11111111111111111111111111111111111111112' --SOL
    and swap_to_mint in ('EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v','Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB') --USDC,USDT
    and swap_to_amount > 0
    and swap_from_amount > 0
    and succeeded = 'TRUE'
    and block_timestamp >= CURRENT_DATE - {{Period}}
    group by 1)


    select
    date_trunc('day',block_timestamp) as date,
    address_name,
    count (distinct tx_id) as Sales_Count,
    count (distinct purchaser) as Buyers_Count,
    count (distinct seller) as Sellers_Count,
    count (distinct mint) as Tokens_Count,
    count (distinct marketplace) as Markets_Count,
    sum (sales_amount) as Total_SOL_Volume,
    sum (sales_amount*Solprice) as Total_USD_Volume,
    avg (sales_amount) as Average_SOL_Volume,
    avg (sales_amount*SOLPrice) as Average_USD_Volume,
    median (sales_amount) as Median_SOL_Volume,
    median (sales_amount*SOLPrice) as Median_USD_Volume,
    Min (sales_amount) as Min_SOL_Volume,
    Min (sales_amount*SOLPrice) as Min_USD_Volume,
    Run a query to Download Data