This is my SQL and its a snippet from the Select Statement... it is running fine, but now i have to remove the hardcoded values from the CAST ... where i enter the Decimal(38,2) i want that to be replaced from the BaseCurrencyDP.NumberOfDecimalPlaces
But it says Integer expected, and this column NumberofDecimalPlaces
in a tinyint
.
please guide
select distinct
a,
b,
c,
CASE
When @userOriginalCurrencyCode IS NOT NULL -- Case For Original Currency Filled in Criteria .
Then SUM(CASE WHEN EmployeeHeader.EmployeePremiumType = 2 THEN EmployeeAmount.TransactionClosedAmountOriginal ELSE 0 END)
When @userAccountingCurrencyCode IS NOT NULL
THEN SUM(CASE WHEN EmployeeHeader.EmployeePremiumType = 2 THEN EmployeeAmount.TransactionClosedAmountAccounting ELSE 0 END )
ELSE CASE
WHEN (select COUNT( DISTINCT( EmployeeAmountGroup.OriginalCurrencyCode )) from user.EmployeeAmountGroup Where EmployeeAmountGroup.EmployeeHeaderID = EmployeeHeader.EmployeeHeaderID )<>1
THEN
CASE WHEN(select COUNT( DISTINCT( EmployeeAmountGroup.AccountingCurrencyCode )) from user.EmployeeAmountGroup Where EmployeeAmountGroup.EmployeeHeaderID = EmployeeHeader.EmployeeHeaderID)<>1
THEN
CAST(ROUND(SUM(CASE WHEN EmployeeHeader.EmployeePremiumType = 2 THEN EmployeeAmount.TransactionClosedAmountBase ELSE 0 END ),BaseCurrencyDP.NumberOfDecimalPlaces) AS Decimal(38,2))
ELSE CAST(ROUND(SUM(CASE WHEN EmployeeHeader.EmployeePremiumType = 2 THEN EmployeeAmount.TransactionClosedAmountAccounting ELSE 0 END ),BaseCurrencyDP.NumberOfDecimalPlaces) AS Decimal(38,2))
END
ELSE CAST(ROUND(SUM(CASE WHEN EmployeeHeader.EmployeePremiumType = 2 THEN EmployeeAmount.TransactionClosedAmountOriginal ELSE 0 END ),BaseCurrencyDP.NumberOfDecimalPlaces) AS Decimal(38,2))
END
End as TotalClosedAmount,
Please guide