binhachon24. [Easy] Unique Addresses - Total
    Updated 2021-11-19
    with all_deposit as(
    select origin_address, tx_id, block_timestamp, row_number() over (partition by origin_address order by block_timestamp asc) as row_number from ethereum.udm_events
    where tx_id in (
    select distinct tx_id from aave.deposits
    where date_trunc('Week', block_timestamp) > getdate() - interval'12 months'
    and date_trunc('Week', block_timestamp) < getdate() - interval'2 days'
    )
    ),
    first_deposit as(
    select origin_address, tx_id, block_timestamp from all_deposit
    where row_number = 1
    ),
    all_borrow as(
    select origin_address, tx_id, block_timestamp, row_number() over (partition by origin_address order by block_timestamp asc) as row_number from ethereum.udm_events
    where tx_id in (
    select distinct tx_id from aave.borrows
    where date_trunc('Week', block_timestamp) > getdate() - interval'12 months'
    and date_trunc('Week', block_timestamp) < getdate() - interval'2 days'
    )
    ),
    first_borrow as(
    select origin_address, tx_id, block_timestamp from all_borrow
    where row_number = 1
    ),
    all_flashloan as(
    select origin_address, tx_id, block_timestamp, row_number() over (partition by origin_address order by block_timestamp asc) as row_number from ethereum.udm_events
    where tx_id in (
    select distinct tx_id from aave.flashloans
    where date_trunc('Week', block_timestamp) > getdate() - interval'12 months'
    and date_trunc('Week', block_timestamp) < getdate() - interval'2 days'
    )
    ),
    first_flashloan as(
    select origin_address, tx_id, block_timestamp from all_flashloan
    where row_number = 1
    )
    Run a query to Download Data