Which function in SQL is used to round off to decimal places?

ROUND() function :

This function in SQL Server is used to round off a specified number to specified decimal places.

Features :

  • This function is used to round off a specified number to a specified decimal places.
  • This function accepts only all type of numbers i.e., positive, negative, zero.
  • This function accepts fraction numbers.
  • This function always returns the number after rounded to the specified decimal places.

Syntax :

ROUND(number, decimals, operation)

Parameter :

This method accepts three parameters as given below :

  • number : Specified number to be rounded off.
  • decimals : Specified number of decimal places up to which the given number is to be rounded.
  • operation : This is optional parameter. If it’s value is 0, it rounds the result to the number of decimal. If another value than 0, it truncates the result to the number of decimals. Default value is 0

Returns :

It returns the number after rounded to the specified places.

Example:

Getting a rounded number up to next two decimal places.

SELECT ROUND(12.3456, 2);

Output :

12.3500