cloudr3nGrabSG - Average Voucher Used byUser
    Updated 2024-02-14
    SELECT
    avg(total_amount),
    median(total_amount),
    max(total_amount),
    min(total_amount)

    FROM (


    SELECT
    sum(amount) as total_amount,
    from_address
    from (
    SELECT
    block_timestamp,
    tx_hash,
    decoded_log:from as from_address,
    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 from_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
    26.646879536521000.1
    1
    27B
    31s