SQL version = 2005.
The following query produces the result 2.000000. I would like it to show just 2.
How do i remove decimal places from the result ?
SELECT ROUND(SUM([Total Order (mins)])/60, 0) as [Total Cutting Time (Hours) Saw 50] FROM [IT_REPORTS].[dbo].[cutting_data] WHERE [AssignedCuttingDate] = DATEADD(dd, DATEDIFF(dd, 0, getdate()), 0) and [Saw No] = '50'
The problem with round()
is that the value changes, but not necessarily the type . So, you might get a bunch of trailing zeros, as you have noticed.
My advice is to convert to a decimal (or integer):
SELECT CAST(SUM([Total Order (mins)])/60 as DECIMAL(10, 0)) as [Total Cutting Time (Hours) Saw 50]
FROM [IT_REPORTS].[dbo].[cutting_data]
WHERE [AssignedCuttingDate] = DATEADD(day, DATEDIFF(day, 0, getdate()), 0) AND
[Saw No] = '50';
You can also use str()
to convert to a string.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.