dr18882023-03-13 04:30 PM
    Updated 2023-03-13
    with A as
    (
    select
    BLOCK_TIMESTAMP::Date as BTD,
    FROM_ADDRESS as FA,
    sum(RAW_AMOUNT) as SRMF
    from avalanche.core.fact_token_transfers
    where CONTRACT_ADDRESS = lower('0x152b9d0FdC40C096757F570A51E494bd4b943E50')
    group by 1,2
    ),
    B as
    (
    select
    TO_ADDRESS as TA,
    sum(RAW_AMOUNT) as SRMT
    from avalanche.core.fact_token_transfers
    where CONTRACT_ADDRESS = lower('0x152b9d0FdC40C096757F570A51E494bd4b943E50')
    group by 1
    ),
    C as
    (
    select
    BTD, FA, SRMF,SRMT
    from
    A
    Left JOIN
    B
    on
    A.FA=B.TA
    --group by 1
    --group by A.FA
    )
    select
    BTD,
    sum(case when SRMT-SRMF >0 then 1 else 0 end) as CHT,
    sum(CHT) over (order by BTD) as SCHT
    Run a query to Download Data