binhachonNet Swapping Rations - Lowest 10
    Updated 2022-01-15
    with swap_from as (
    select
    case
    when position('-', from_asset, 1) = 0 then from_asset else
    substr(from_asset, 1, position('-', from_asset, 1) - 1) end
    as from_asset,
    sum(from_amount) as from_amount,
    sum(from_amount_usd) as from_amount_usd
    from thorchain.swaps
    group by from_asset
    ),
    swap_to as (
    select
    case
    when position('-', to_asset, 1) = 0 then to_asset else
    substr(to_asset, 1, position('-', to_asset, 1) - 1) end
    as to_asset,
    sum(to_amount) as to_amount,
    sum(to_amount_usd) as to_amount_usd
    from thorchain.swaps
    group by to_asset
    ),
    swap_ratio as (
    select
    from_asset as asset,
    from_amount,
    from_amount_usd,
    to_amount,
    to_amount_usd,
    from_amount / to_amount as amount_ratio,
    from_amount_usd / to_amount_usd as amount_usd_ratio
    from swap_from
    left join swap_to
    on from_asset = to_asset
    )
    select * from swap_ratio
    Run a query to Download Data