Updated 2022-07-23
    with source as (
    select
    block_number,
    from ethereum.core.fact_transactions
    where TX_JSON:receipt:logs[0]:decoded:inputs:to = '0x397ff1542f962076d0bfe58ea045ffa2d347aca0'
    and block_number > '14000000'
    and block_number < '15180000'
    and eth_value > 0.01
    ),
    price as (
    select
    source.block_number as bn,
    avg(amount_in_usd/amount_in) as average
    from ethereum.core.ez_dex_swaps s
    inner join source on source.block_number = s.block_number
    where TOKEN_OUT = '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48'
    and TOKEN_IN = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'
    and s.block_number >= source.block_number - 100
    and s.block_number <= '15180000'
    group by bn
    )
    select Tx_hash, eth_value*average, block_number
    from ethereum.core.fact_transactions
    inner join price on block_number = bn
    group by 1, 2, 3