farid-c9j0VMpart3-daily
    Updated 2022-12-20
    select date_trunc(day,block_timestamp) as date,
    case
    when ORIGIN_TO_ADDRESS = lower('0xef1c6e67703c7bd7107eed8303fbe6ec2554bf6b')
    and ORIGIN_FUNCTION_SIGNATURE = lower('0x24856bc3')
    and EVENT_TYPE = 'sale' then 'Uniswap Nft Aggregator' else AGGREGATOR_NAME end as category,
    count(distinct tx_hash) as "transactions",
    count(distinct nft_address) as "collections",
    count(distinct tokenid) as "nfts",
    count(distinct buyer_address) as "buyers",
    count(distinct seller_address) as "sellers",
    count(tokenid)/"transactions" as "count nft per tx",
    sum(price) as "volume",
    sum(price_usd) as "volume_usd",
    avg(price_usd) as "price",
    SUM(CREATOR_FEE_USD) as "Royalty",
    AVG(CREATOR_FEE_USD) as "Average Royalty",
    Median(CREATOR_FEE_USD) as "Median",
    Max(CREATOR_FEE_USD) as "Max",
    Min(CREATOR_FEE_USD) as "Min",
    DIV0("Royalty" , "volume_usd") * 100 as "Average Royalty Percentage",
    sum("transactions") over (partition by category order by date) as "cum_transactions",
    sum("buyers") over (partition by category order by date) as "cum_buyers",
    sum("sellers") over (partition by category order by date) as "cum_sellers",
    sum("volume_usd") over (partition by category order by date) as "cum_volume_usd",
    DIV0("Royalty" , "volume_usd") * 100 as "Average Royalty Percentage"

    from ethereum.core.ez_nft_sales

    where category is not null
    and EVENT_TYPE = 'sale'
    and BLOCK_TIMESTAMP >= CURRENT_DATE - 14
    group by 1,2
    Run a query to Download Data