SQL Server ROUND Function Examples

Let’s look at some example of the ROUND function in SQL Server. Understanding SQL Server ROUND Function with examples, will help in learning the concept better.

Example 1

In this example, we are rounding off a number up to next two decimal places.

SELECT ROUND(12.3456, 2);

Output :

12.3500

Example 2 :

In this example, we are rounding off the number to the next two decimal places with the operational parameter 1 which says only to truncate the specified number (-23.456) to the given decimal places i.e., 2.

SELECT ROUND(12.3456, 2, 1);

Output :

12.3400

Example 3 :

In this example, we are using ROUND() function with a variable and getting the rounded number to -2 decimal place.

DECLARE @Parameter_Value FLOAT;
SET @Parameter_Value = -2;
SELECT ROUND(123.4567, @Parameter_Value);

Output :

100.0000

Example 4

In this example, we are rounding number to the zero number of decimal places.

SELECT ROUND(123.467, 0);

Output :

123.000

SQL Server ROUND() Function

The SQL Server ROUND() function rounds off a specified number to a decimal place.

Similar Reads

ROUND in SQL Server

The ROUND() function in SQL Server rounds off a number to a specified decimal place. It accepts positive, negative, and zero values....

Syntax

The SQL Server ROUND Function syntax is:...

SQL Server ROUND Function Examples

Let’s look at some example of the ROUND function in SQL Server. Understanding SQL Server ROUND Function with examples, will help in learning the concept better....

Important Points About SQL Server ROUND Function

The ROUND() function is used to round off a specified number to a specified number of decimal places. It accepts various types of numbers, including positive, negative, and zero. The return type of the ROUND() function depends on the input number type. The ROUND() function uses the rounding-to-the-nearest-digit algorithm....