December 1, 2011 at 10:48 am
Platform: (microsoft SQL 2005 server)
I have a SQL query that outputs values in this format: "73.190002" . I would like to format the output so it looks like "73.1".
select PointName, pointValue from DataTable
Thanks
December 1, 2011 at 11:08 am
CAST(PointValue AS dec(10,1))
This one was simple.
December 1, 2011 at 11:33 am
Try this:
DECLARE @D DECIMAL(18,6)
SET @D = 73.190002
SELECT CAST(CAST(ROUND(@D,1,2) AS VARCHAR(10)) AS DECIMAL(18,1)),CAST(@d AS dec(10,1)) AS 'OOPS'
Results:
(No column name)OOPS
73.1 73.2
December 1, 2011 at 12:16 pm
Slightly shorter to use the Function (truncate) of the ROUND function:CAST(ROUND(@D,1, 1) AS DECIMAL (18,1))
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply