SQL round,FLOOR

  • Hi,

    I need

    -13599.99 as 13600

    162157.36 as 162157

    7415781.64 AS 7415782

    How can I achive that ?

    thanks,

  • the round function has an optional parameter for the # of decimal places;

    the Absolute value function converts any number to positive:

    /*

    -13599.99 as 13600

    162157.36 as 162157

    7415781.64 AS 7415782

    */;With MySampleData([myval])

    AS

    (

    SELECT '-13599.99' UNION ALL

    SELECT '162157.36' UNION ALL

    SELECT '7415781.64'

    )

    SELECT

    ROUND([myval],0) As Rounded,

    ABS(ROUND([myval],0)) As PosiRounded

    FROM MySampleData

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Thanks that worked perfectly!

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply