Ali3NDistribution of SOLANA NFTs Sales Over Time (FLOW DOWN BAD)
    Updated 2023-05-03
    with flowpricet as (
    select recorded_hour::Date as day,
    avg (close) as FLOWPrice
    from flow.core.fact_hourly_prices
    where token ilike 'flow'
    group by 1),

    solpricet as (
    select recorded_hour::Date as day,
    avg (close) as SOLPrice
    from solana.core.ez_token_prices_hourly
    where symbol ilike 'sol'
    group by 1),

    maintable as (
    select date_trunc ({{Time_Interval}},block_timestamp) as date,
    'Flow NFTs' as NFTCollection,
    tx_id,
    buyer,
    nft_id,
    case when t1.currency ='A.1654653399040a61.FlowToken' then t1.price * t2.flowprice else t1.price end as Volume
    from flow.core.ez_nft_sales t1 join flowpricet t2 on t1.block_timestamp::date = t2.day
    where tx_succeeded ilike 'true'
    and block_timestamp >= current_date - 180
    and nft_collection in ('A.0b2a3299cc857e29.TopShot','A.e4cf4bdc1751c65d.AllDay','A.329feb3ab062d289.UFC_NFT','A.87ca73a41bb50ad5.Golazos','A.321d8fcde05f6e8c.Seussibles')

    union all

    select date_trunc ({{Time_Interval}},block_timestamp) as date,
    'Ethereum NFTs' as NFTCollection,
    tx_hash,
    buyer_address,
    tokenid,
    price_usd as Volume
    from ethereum.core.ez_nft_sales
    where block_timestamp >= current_date - 180
    Run a query to Download Data