nilocollections
    Updated 2023-06-07
    select
    date_trunc('day', block_timestamp) as Date,
    contract_name,
    count(DISTINCT tx_id) as Txn,
    count(DISTINCT buyer) as Buyers,
    count(DISTINCT seller) as Sellers,
    SUM(
    CASE
    WHEN CURRENCY = 'A.1654653399040a61.FlowToken' THEN PRICE * FLOW_USD
    ELSE PRICE
    END
    ) AS USD,
    rank() over (
    partition by
    contract_name
    order by
    Date asc
    ) as Day,
    sum(Txn) over (
    partition by
    contract_name
    order by
    date
    ) as cum_sales,
    sum(Buyers) over (
    partition by
    contract_name
    order by
    date
    ) as cum_Buyers,
    sum(USD) over (
    partition by
    contract_name
    order by
    date
    ) as cum_USD