SELECT
CurrencyCodeFrom,
CurrencyCodeTo,
MidRevalRate,
MultiplierRate,
RevalRate,
CurrencyMarketCode,
Added,
Modified,
UpdateReason
FROM
[InsightWarehouse].[dbo].[DimCurrency] as dc
INNER JOIN
[InsightWarehouse].[dbo].[FactCurrency] as fc
ON fc.CurrencyId = dc.CurrencyId
AND fc.BusinessDate = '2018-11-27'
AND ( CurrencyCodeFrom <> 'KHR' OR CurrencyCodeTo <> 'KHR')
Resultado
CurrencyCodeFrom CurrencyCodeTo MidRevalRate MultiplierRate RevalRate CurrencyMarketCode
THB KHR 122.500000000 122.500000000 1.000000000 1
THB KHR 122.750000000 122.750000000 1.000000000 10
THB KHR 122.500000000 122.500000000 1.000000000 3
THB KHR 122.750000000 122.750000000 1.000000000 5
THB KHR 122.750000000 122.750000000 1.000000000 7
THB KHR 122.750000000 122.750000000 1.000000000 9
USD KHR 4035.000000000 4035.000000000 1.000000000 1
USD KHR 4047.500000000 4047.500000000 1.000000000 10
USD KHR 4035.000000000 4035.000000000 1.000000000 3
USD KHR 4047.500000000 4047.500000000 1.000000000 5
USD KHR 4047.500000000 4047.500000000 1.000000000 7
USD KHR 4047.500000000 4047.500000000 1.000000000 9
Eu quero ordenar o CurrencyMarketCode
DESC por manter o grupoCurrencyCodeFrom
CurrencyCodeTo
Deveria estar
CurrencyCodeFrom CurrencyCodeTo MidRevalRate MultiplierRate RevalRate CurrencyMarketCode
THB KHR 122.500000000 122.500000000 1.000000000 1
THB KHR 122.500000000 122.500000000 1.000000000 3
THB KHR 122.750000000 122.750000000 1.000000000 5
THB KHR 122.750000000 122.750000000 1.000000000 7
THB KHR 122.750000000 122.750000000 1.000000000 9
THB KHR 122.750000000 122.750000000 1.000000000 10
USD KHR 4035.000000000 4035.000000000 1.000000000 1
USD KHR 4035.000000000 4035.000000000 1.000000000 3
USD KHR 4047.500000000 4047.500000000 1.000000000 5
USD KHR 4047.500000000 4047.500000000 1.000000000 7
USD KHR 4047.500000000 4047.500000000 1.000000000 9
USD KHR 4047.500000000 4047.500000000 1.000000000 10
Seu comentário
não corresponde ao seu resultado porque
CurrencyMarketCode
no seu resultado está em ordem crescente.Como @ypercube comentou, por que não um simples
ORDER BY CurrencyCodeFrom, CurrencyCodeTo, CurrencyMarketCode
resolver seu problema?Os resultados parecem corresponder ao resultado desejado.