Table of Contents
ROUND Function in SQL Server is easier to understand when the core ideas are paired with practical examples. The sections below explain the topic clearly, highlight useful steps, and point out details that can prevent common errors.
This guide will show you in detail how to use the SQL Server ROUND () function with syntax and examples to better visualize and capture functions better.
Describe
The ROUND function in SQL Server helps round numbers to a certain decimal place.
Syntax
To use the ROUND function in SQL Server, we use the following syntax:
ROUND(number, decimal, operation)
Parameters :
- number: number passed to round
- Decimal : The number of decimal places is rounded to. This value must be a positive or negative integer. If this parameter is omitted, the ROUND function will round the number to 0 decimal places.
- operation: parameter not required. The operation can be any other numeric value. When it is 0 (or omitted), the ROUND function will round the result into a decimal. If the operation is any value other than 0, the ROUND function will cut the result into a decimal.
Principle of rounding :
When you round the number, the system will check the number in position (decimal + 1):
- If the number is greater than 4, the number in the decimal position will add 1. The numbers at the back become 0
- If the number is less than 5, the number in the decimal position will remain the same. The numbers on the back become 0
For instance, we have a decimal number of 423.3241

- ROUND function can be used in later versions of SQL Server: SQL Server 2017, SQL Server 2016, SQL Server 2014, SQL Server 2012, SQL Server 2008 R2, SQL Server 2008, and SQL Server 2005.
For instance,
Take a look and explore some examples of ROUND functions in SQL Server.
Example 1: Round the numbers
SELECT ROUND(125.315, 2);Result: 125.320 (k?t qu? ???c làm tròn vì tham s? th? 3 b? b? qua)SELECT ROUND(125.315, 2, 0);Result: 125.320 (k?t qu? ???c làm tròn vì tham s? th? 3 là 0)SELECT ROUND(125.315, 2, 1);Result: 125.310 (k?t qu? b? c?t b?t vì tham s? th? 3 khác 0)SELECT ROUND(125.315, 1);Result: 125.300 (k?t qu? ???c làm tròn vì tham s? th? 3 b? b? qua)SELECT ROUND(125.315, 0);Result: 125.000 (k?t qu? ???c làm tròn vì tham s? th? 3 b? b? qua)SELECT ROUND(125.315, -1);Result: 130.000 (k?t qu? ???c làm tròn vì tham s? th? 3 b? b? qua)SELECT ROUND(125.315, -2);Result: 100.000 (k?t qu? ???c làm tròn vì tham s? th? 3 b? b? qua)
Example 2: We have the following data table
1. Get the sub-column and rate of the website, rounding the ratio to the 2nd decimal place
SELECT Chuyenmuccon, ROUND(Tyle, 2) AS TylemoiFROM Tipsmake;Result:Chuyenmuccon TylemoiSQL Server 74.63Facebook 58.99Python 36.22JavaScript 42.68Google Chrome 94.88Instagram 82.16
Next lesson: SIGN function in SQL Server
FAQ
What should you know about describe?
The ROUND function in SQL Server helps round numbers to a certain decimal place.
What should you know about syntax?
To use the ROUND function in SQL Server, we use the following syntax:
What should you know about for instance,?
Take a look and explore some examples of ROUND functions in SQL Server.
Reader Comments 0
Sign in with email or Google to join the discussion.