Collections:
ROUND() - Rounding Values to Specific Precisions in SQL Server
How To Round a Numeric Value To a Specific Precision in SQL Server Transact-SQL?
✍: FYIcenter.com
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
⇒ RAND() - Generating Random Numbers in SQL Server
⇐ FLOOR, CEILING, ROUND - Converting Values to Integers in SQL Server
⇑ Numeric Expressions and Functions in SQL Server Transact-SQL
2017-03-11, 5372🔥, 0💬
Popular Posts:
How To Convert Binary Strings into Integers in SQL Server Transact-SQL? Binary strings and integers ...
How To Use GO Command in "sqlcmd" in SQL Server? "sqlcmd" is a command line client application to ru...
How to set database to be READ_ONLY in SQL Server? Databases in SQL Server have two update options: ...
How To List All Login Names on the Server in SQL Server? If you want to see a list of all login name...
What Are Bitwise Operations in SQL Server Transact-SQL? Bitwise operations are binary operations per...