behnamqDestination that are in both the top 50 count and top 50 sum amount lists based
    Updated 2022-07-27
    WITH tx_sol as (
    SELECT BLOCK_TIMESTAMP, tx_id, INSTRUCTION:parsed:info:authority as authority, INSTRUCTION:parsed:info:source as source,
    INSTRUCTION:parsed:info:destination as destination, INSTRUCTION:parsed:info:amount as amount
    From solana.core.fact_events
    Where SUCCEEDED = TRUE and index = 2 and event_type = 'transfer' and PROGRAM_ID = 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'
    )

    , top_50_source as (
    SELECT top 50 source, COUNT(*) as count_tx, sum(amount) as total_amount from tx_sol
    GROUP by 1
    order by 2 desc
    )

    , top_50_destination as (
    SELECT top 50 destination, COUNT(*) as count_tx, sum(amount) as total_amount from tx_sol
    GROUP by 1
    order by 2 desc
    )

    , top_50_source_amount as (
    SELECT top 50 source, COUNT(*) as count_tx, sum(amount) as total_amount from tx_sol
    GROUP by 1
    order by 3 desc
    )

    , top_50_destination_amount as (
    SELECT top 50 destination, COUNT(*) as count_tx, sum(amount) as total_amount from tx_sol
    GROUP by 1
    order by 3 desc
    )

    SELECT * --top 50 destination, COUNT(*) as count_tx, sum(amount) as total_amount
    from top_50_destination as tpd join top_50_destination_amount as tpda
    on tpd.destination=tpda.destination
    --GROUP by 1
    Run a query to Download Data