I use the following query on the SQL Server 2008 database of a 3rd party product to generate some reports.
SELECT ROUND(SUM(Price),0,1) AS SumNetPrice FROM Transactions
Eg
SUM(Price): 1.2345678
ROUND(SUM(Price),0,1): 1
This has worked fine until now and removed all of the decimal places. In fact curiously the result was truncated even if I didn’t specify the 3rd parameter as per the MSDN information http://msdn.microsoft.com/en-us/library/ms175003.aspx on the ROUND function.
The 3rd party company has now changed the data type of the Price column from ‘real’ to decimal(22, 7). Unfortunately this now means that I always get 7 decimal places even when I use the truncate option of the ROUND function. So now I get:
ROUND(SUM(Price),0,1): 1.0000000
Shouldn’t the ROUND(expression,0,1) truncate the result so I don’t get any decimal places? How can I remove these decimal places from the result in the SQL query?
1 Answer