cloudr3nGrabSG - Average Voucher Used by Store
    Updated 2024-02-14
    -- decoded_log:to can be the same when origin_to_address is different
    SELECT
    avg(total_amount),
    median(total_amount),
    max(total_amount),
    min(total_amount)

    FROM (
    SELECT
    sum(amount) as total_amount,
    to_address
    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
    order by 1 desc
    )
    Last run: about 1 year agoAuto-refreshes every 12 hours
    AVG(TOTAL_AMOUNT)
    MEDIAN(TOTAL_AMOUNT)
    MAX(TOTAL_AMOUNT)
    MIN(TOTAL_AMOUNT)
    1
    129.293661972311848.10.1
    1
    31B
    36s