Sandeshflow_FEES_2
    Updated 2022-11-16
    with flow_price as
    (
    select date_trunc('hour',timestamp) as time, avg(price_usd) as price
    from flow.core.fact_prices
    where symbol = 'FLOW'
    and source='coinmarketcap'
    group by time
    ),
    flow_fee as
    (
    select tx_id,event_data:"amount" as tx_fee from flow.core.fact_events
    where 1=1
    -- and tx_id='45157287d12a4901806e9154e6a0f63c07b27de724df406519474413a0ff779b'
    and event_type='FeesDeducted'
    and block_timestamp > CURRENT_DATE - interval ' 1 month'
    ),
    -- rec as
    -- (
    -- select tx_id,event_data:"amount" as amount, event_data:"to" as to_address from flow.core.fact_events
    -- where 1=1
    -- -- and tx_id='45157287d12a4901806e9154e6a0f63c07b27de724df406519474413a0ff779b'
    -- and event_type='TokensDeposited'
    -- and block_timestamp > CURRENT_DATE - interval ' 1 month'
    -- ),
    flow_combined as
    (
    select t.*,flow_fee.tx_fee,'0x' as to_address from flow.core.fact_transactions t inner join flow_fee on t.tx_id=flow_fee.tx_id
    -- inner join rec r on t.tx_id=r.tx_id
    ),
    flow_fee_table as
    (
    select
    'flow' as chain,
    ft.BLOCK_HEIGHT as block_number,
    Run a query to Download Data