Updated 2022-06-21
    with a as
    (select
    *
    from (
    with
    first_time as (
    select
    date_trunc('hour', block_timestamp) as first_times,
    tokenflow_eth.hextoint(topics[1])::string as tokenID
    from ethereum.core.fact_event_logs
    where contract_address = lower('0x4b10701Bfd7BFEdc47d50562b76b436fbB5BdB3B')
    and topics[0]::string = '0x1106ee9d020bfbb5ee34cf5535a5fbf024a011bd130078088cbf124ab3092478'
    )
    , firsts as (
    select
    sum(event_inputs:amount/1e18) as mint_price,
    event_inputs:nounId as nounid1
    from ethereum.core.fact_event_logs where contract_address = lower('0x55e0f7a3bb39a28bd7bcc458e04b3cf00ad3219e') and tx_status = 'SUCCESS' and event_name = 'AuctionSettled' group by 2
    ),
    second_time as (
    select
    date_trunc('hour', block_timestamp) as second_times,
    tokenid as nounid2,
    sum(price) as sale_price
    from ethereum.core.ez_nft_sales where nft_address = lower('0x4b10701Bfd7BFEdc47d50562b76b436fbB5BdB3B') and event_type = 'sale' group by 1,2
    )
    select
    datediff(hour, first_times, second_times) as period,
    nounid2 as noun_id ,sum(sale_price - mint_price) as diff_price,
    mint_price, sale_price
    from first_time join firsts on tokenid =nounid1
    join second_time on nounid2= tokenID
    where sale_price != 0 or sale_price>0
    group by 1,2,4,5
    order by 3 DESC)
    Run a query to Download Data