format number in a query output

  • 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

  • CAST(PointValue AS dec(10,1))

    This one was simple.

  • 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

    If everything seems to be going well, you have obviously overlooked something.

    Ron

    Please help us, help you -before posting a question please read[/url]
    Before posting a performance problem please read[/url]

  • 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