Home >> FAQs/Tutorials >> SQL Server FAQ

SQL Server FAQ - ROUND() - Rounding Values to Specific Precisions

By: FYIcenter.com

(Continued from previous topic...)

How To Round a Numeric Value To a Specific Precision?

Sometimes you need to round a numeric value to a specific precision. For example, you may want to round values in your financial statement to the precision of 1000.00. This can be done by the ROUND() function with the following syntax:

ROUND(value, precision, type)

value: The input value to be rounded.

precision: The location of the precision digit relative 
   to the decimal point. 

type: 0 - Round to nearest value; 
   1 - Truncate to a lower value.

The tutorial exercise below gives some good examples of how to use the ROUND() function:

SELECT ROUND(1234.5678, 0, 0);
SELECT ROUND(1234.5678, -3, 0);
SELECT ROUND(1234.5678, -4, 0);
SELECT ROUND(1234.5678, 3, 0);
SELECT ROUND(1234.5678, 3, 1);
GO
1235.0000
1000.0000
0.0000
1234.5680
1234.5670

(Continued on next topic...)

  1. What Is an Expression?
  2. What Are Arithmetic Operators?
  3. What Happens to an Arithmetic Operation with Two Different Data Types?
  4. How To Convert a Numeric Expression from One Data Type to Another?
  5. How To Convert Numeric Expression Data Types by Assignment Operations?
  6. How To Convert Numeric Expression Data Types using the CAST() Function?
  7. How To Convert Numeric Expression Data Types using the CONVERT() Function?
  8. How To Convert Character Strings into Numeric Values?
  9. What Happens When Converting Big Values to Integers?
  10. What Happens When Converting Big Values to NUMERIC Data Types?
  11. What Are the Mathematical Functions Supported by SQL Server 2005?
  12. How To Convert Numeric Values to Integers?
  13. How To Round a Numeric Value To a Specific Precision?
  14. How To Generate Random Numbers with the RAND() Function?

Related Articles:

More...


Other Tutorials/FAQs:

More...


Related Resources:

More...


Selected Jobs:

More...