Ali3NAverage Net Earned/Lost Volume From Profit/Loss By Exchange Art NFT Traders ($USD)
    Updated 2023-07-20
    with solpricet as (
    select recorded_hour::date as day,
    avg (close) as SOLPrice
    from solana.core.fact_token_prices_hourly
    where symbol = 'SOL'
    group by 1),
    selltable as (
    select seller,
    sum (sales_amount*solprice) as Total_Volume
    from solana.core.fact_nft_sales t1 join solpricet t2 on t1.block_timestamp::date = t2.day
    where succeeded = 'TRUE'
    and marketplace = 'exchange art'
    group by 1),

    buytable as (
    select purchaser,
    sum (sales_amount*solprice) as Total_Volume
    from solana.core.fact_nft_sales t1 join solpricet t2 on t1.block_timestamp::date = t2.day
    where succeeded = 'TRUE'
    and marketplace = 'exchange art'
    group by 1),

    maintable as (
    select t1.seller,
    sum (t1.Total_Volume - t2.Total_Volume) as Profit
    from selltable t1 join buytable t2 on t1.seller = t2.purchaser
    group by 1)

    select avg (profit) from maintable

    Run a query to Download Data