KaskoazulgALGO3 swaps by ASA
    Updated 2022-04-29
    with swap_to as (
    select --s.block_timestamp::date as fecha,
    case
    when s.swap_to_asset_id != 0 then a.asset_name
    else 'ALGO'
    end as token_to,
    count (tx_group_id) as swaps,
    sum(swap_from_amount) as volume
    from algorand.swaps s
    left join algorand.asset a
    on s.swap_to_asset_id = a.asset_id
    where swap_from_asset_id = 694432641
    group by 1--,2
    ),

    swap_from as(
    select --s.block_timestamp::date as fecha,
    case
    when s.swap_from_asset_id != 0 then a.asset_name
    else 'ALGO'
    end as token_from,
    count (tx_group_id) as swaps,
    sum(swap_to_amount) as volume
    from algorand.swaps s
    left join algorand.asset a
    on s.swap_from_asset_id = a.asset_id
    where swap_to_asset_id = 694432641
    group by 1--,2
    )

    select s.token_to,
    s.swaps as swaps_to,
    s.volume as volume_to,
    f.swaps as swaps_from,
    f.volume as volume_from