binhachonMost Common Transactions - #3
    Updated 2022-06-25
    with metamask_users as (
    select
    distinct origin_from_address
    from ethereum.core.fact_event_logs
    where contract_address = lower('0x881D40237659C251811CEC9c364ef91dC08D300C')
    ),
    total_users as (
    select
    count(*) as total_number
    from metamask_users
    ),
    top_contracts as (
    select
    contract_address,
    count(distinct origin_from_address) as frequency,
    row_number() over (order by frequency desc) as rank
    from ethereum.core.fact_event_logs
    where origin_from_address in (select origin_from_address from metamask_users)
    and contract_address != lower('0x881D40237659C251811CEC9c364ef91dC08D300C')
    group by 1
    order by 2 desc
    limit 10
    ),
    top_actions as (
    select
    contract_address,
    event_name,
    count(distinct origin_from_address) as frequency
    from ethereum.core.fact_event_logs
    where origin_from_address in (select origin_from_address from metamask_users)
    and contract_address in (select contract_address from top_contracts)
    group by 1, 2
    qualify row_number() over (partition by contract_address order by frequency desc) = 1
    )
    select
    top_actions.*,
    Run a query to Download Data