Afonso_DiazGrouping Transactions
    Updated 2025-05-07
    with

    main as (
    select
    tx_id,
    block_timestamp,
    iff(f.value:from in ('CAOTMWRKNMV5GWSVOMWCTCM5ZZFEQFUSWNLCZXA2KAXD4YG5A4DIPNFT'), f.value:to, f.value:from) as user,
    f.value:asset_code as symbol,
    f.value:amount as amount,
    iff(f.value:from in ('CAOTMWRKNMV5GWSVOMWCTCM5ZZFEQFUSWNLCZXA2KAXD4YG5A4DIPNFT'), 'Bridge To Stellar', 'Bridge From Stellar') as bridge_type
    from
    stellar.core.ez_operations
    join
    lateral flatten (input => asset_balance_changes) as f
    where
    'CAOTMWRKNMV5GWSVOMWCTCM5ZZFEQFUSWNLCZXA2KAXD4YG5A4DIPNFT' in (f.value:from, f.value:to)
    and successful
    and f.value:asset_type != 'native'
    )

    select
    bridge_type,
    case
    when amount = 1 then '🧹 Dust ($1)'
    when amount > 1 and amount < 5 then '🐜 Tiny ($1 - $5)'
    when amount >= 5 and amount < 10 then '🐁 Very Small ($5 - $10)'
    when amount >= 10 and amount < 100 then '🟢 Small ($10 - $100)'
    when amount >= 100 and amount < 1000 then '🔵 Medium ($100 - $1K)'
    when amount >= 1000 and amount < 10000 then '🟣 Large ($1K - $10K)'
    when amount >= 10000 and amount < 50000 then '🟠 Very Large ($10K - $50K)'
    when amount >= 50000 and amount < 100000 then '🔴 Huge ($50K - $100K)'
    else '🐋 Whale (≥$100K)'
    end as amount_usd_category,
    count(*) as transaction_count
    from
    main
    QueryRunArchived: QueryRun has been archived