Nige7777portfolio
    Updated 2022-03-01
    -- with cte_blocks as (

    -- select block_id , tx_id
    -- from ethereum.transactions
    -- where (from_address =lower('0x16f2F6eb3AFD95cE06eD9b700EC7D44FAF380C8A') or to_address = lower('0x16f2F6eb3AFD95cE06eD9b700EC7D44FAF380C8A'))
    -- )

    -- ,
    with cte_in as (
    select distinct
    row_number() over (partition by e.contract_address, token_id order by e.block_timestamp) as tf_in_id,
    row_number () over (partition by e.tx_id order by e.block_timestamp) AS tx_rank,
    count (*) over (partition by e.tx_id order by e.block_timestamp) as mintsPerTx,
    e.block_timestamp as timestamp,
    price as EthOut,
    e.contract_address,
    e.project_name,
    t.block_id as blocknumber,
    e.event_to as "to",
    e.event_from as "from",
    e.event_type,
    e.token_id as tokenid,
    e.tx_id
    from ethereum.nft_events e
    join ethereum.transactions t on t.tx_id = e.tx_id and t.block_timestamp = e.block_timestamp
    --join cte_blocks t on t.tx_id = e.tx_id
    where 1=1
    and event_to = lower('0x16f2F6eb3AFD95cE06eD9b700EC7D44FAF380C8A')
    and e.event_type = 'sale'
    order by e.block_timestamp
    ),
    cte_out as (
    select distinct
    row_number() over (partition by e.contract_address, token_id order by e.block_timestamp) as tf_out_id,
    row_number () over (partition by e.tx_id order by e.block_timestamp) AS tx_rank,
    count (*) over (partition by e.tx_id order by e.block_timestamp) as mintsPerTx,
    Run a query to Download Data