Case statement based on alphabetical order of a code

You should be able to use the standard logical expressions, for example like shown below. Alphabetical sort will be applied to determine the outcome.
SELECT CASE WHEN BuyCCY > SellCCY THEN BuyCCY ELSE SellCCY END AS Currency1

If the currency codes can be mixed case, you should convert to the same casing before doing the logical comparisons as in
WHEN UPPER(BuyCCY) > UPPER(SellCCY) THEN BuyCCY

1 Like