cloudr3n2023-09-12 10:23 PM
    Updated 2024-02-01
    -- decoded_log:to can be the same when origin_to_address is different
    SELECT
    date(block_timestamp) as day,
    to_address,
    case when sum(amount) is null then 0 else sum(amount) end as total_amount,
    sum(total_amount) over (partition by to_address order by day asc)
    from (
    SELECT
    block_timestamp,
    tx_hash,
    decoded_log,
    decoded_log:to as to_address,
    decoded_log:ERC20TokenValue*pow(10,-6) as amount
    --count(distinct decoded_log:to),
    --count(distinct origin_to_address)
    FROM
    polygon.core.ez_decoded_event_logs
    WHERE
    contract_address=lower('0xd2d74e2136d60a3c0d252c6de4102a82f2511def')
    and event_name='MerchantPayment'
    and decoded_log:ERC20Token='0xdc3326e71d45186f113a2f448984ca0e8d201995'
    --and decoded_log:tokenIds!=[3]
    )

    group by to_address, day
    order by 1 desc
    Last run: about 1 year ago
    DAY
    TO_ADDRESS
    TOTAL_AMOUNT
    SUM(TOTAL_AMOUNT) OVER (PARTITION BY TO_ADDRESS ORDER BY DAY ASC)
    1
    2024-01-31 00:00:00.000
    0x4bd5042971bebcc67d2e912da8c9faf568483f87
    14326
    2
    2024-01-31 00:00:00.000
    0x7820b9c4ae6bad4fbea97c8aaa9351a8ea932aae
    1121624
    3
    2024-01-30 00:00:00.000
    0xa0e8ff3f07821e1ceae193cc087f60b909584a45
    1051
    4
    2024-01-28 00:00:00.000
    0x0611567147135902f86a139c95a34437bd70d595
    140224
    5
    2024-01-27 00:00:00.000
    0x909d3708755d0a5d87fa0e1a4b442eaa689f49bf
    536
    6
    2024-01-25 00:00:00.000
    0x8348c449d27854036ab8db742f06deb57032d17f
    240377
    7
    2024-01-25 00:00:00.000
    0x487b74c89f761f6d193a372d6afdfe6dd145ade2
    391039.1
    8
    2024-01-25 00:00:00.000
    0xfdeb9b7673849d4958fe41e3664af1aa3716a0fe
    152286
    9
    2024-01-24 00:00:00.000
    0xd16fff8ef5a0b4ba742b4d2197a04d8e627fd589
    10182
    10
    2024-01-24 00:00:00.000
    0x6fb3efeea19e18c9b639773e8def8d70a5475d04
    172.8
    11
    2024-01-23 00:00:00.000
    0x30ff17da068b9c405f176360ec1b2bff27fb84f6
    14253
    12
    2024-01-23 00:00:00.000
    0xcc1d4a58f6f3b8ce5bbb477729da61fd177335c8
    1010
    13
    2024-01-21 00:00:00.000
    0x0d7a64dd147c66bb3009bb831c250cf9ab938fd0
    99
    14
    2024-01-21 00:00:00.000
    0x7820b9c4ae6bad4fbea97c8aaa9351a8ea932aae
    31512
    15
    2024-01-21 00:00:00.000
    0x483846fa6fc7a6018dce12d324229b365ae96e9c
    206674
    16
    2024-01-20 00:00:00.000
    0x4d4bc234ba70219033089d43c509305945494619
    257
    17
    2024-01-19 00:00:00.000
    0x2842ffe77f98c9bef7b0d9c5942f0e453ace8b99
    582
    18
    2024-01-19 00:00:00.000
    0xe87952b76df77a30a0b48f6f201a68a07a10b473
    422450.1
    19
    2024-01-18 00:00:00.000
    0xb122a30e33161fd9dcaa2f609bcd22dd1eadd3cb
    25207.9
    20
    2024-01-16 00:00:00.000
    0x7820b9c4ae6bad4fbea97c8aaa9351a8ea932aae
    1421509
    ...
    594
    46KB
    6s