SQL ROUND Function

Wednesday, December 14, 2011

tags SQL

The SQL ROUND function is used to round a numeric field in a table to the number of decimals specified.

Employees Table

1000John Smith10.25
1001Fred White22.53
1002Jane Scott17.4
1003Samuel Williams9.9

In this example, we want to round the results of the yearsOfService to the nearest whole number.


SELECT ROUND(column_name, decimals)
FROM Table

SELECT employeeName as [Employee Name], ROUND(yearsofService,0) as [Years of Service]
FROM employees


Employee NameYears of Service
John Smith10
Fred White23
Jane Scott17
Samuel Williams10

The SQL ROUND function is very useful when you need to round the numbers in the result set to a specific number of decimal places.

Did you find the page informational and useful? Share it using one of your favorite social sites.

Recommended Books & Training Resources

Head First SQL: Your Brain on SQL A Learners Guide SQL Cookbook