DECLARE @TrvlReportCachRegTemp TABLE
(
  acCurrency nvarchar(5), 
  anAdvancePayment money
);

INSERT INTO 
@TrvlReportCachRegTemp 
SELECT 
acCurrency,
sum(PLACANO_A) as anAdvancePayment 
FROM 
vHR_TrvlReportCachReg
WHERE 
acKey = @acKey
GROUP BY 
acCurrency

SELECT * FROM @TrvlReportCachRegTemp
ORDER BY CASE WHEN acCurrency = dbo.fHE_GetPrimCurrency(GetDate()) THEN 1 ELSE 2 END

