How to round and truncate in SQL

Rounding on the right side of the decimal

ROUND(number, length)

The ROUND method allows you to round numbers up. Length is a namespace for the parameter you want rounded up, 0 for whole number, 1 for the first decimal place.

SELECT Cost, 
       ROUND(Cost,0) AS RoundedCost #rounds up the Cost price to the nearest whole number
FROM Shipments

Rounding on the left side of the decimal

SELECT Profit
ROUND(Duration,-1) AS NearestTen #this rounds up the number to the nearest ten
ROUND(Duration, -2) AS NearestHundred #this rounds up the number to the nearest hundred
FROM Income

Truncate

You can also use the round method to truncate by specifying the third argument in the ROUND method.

SELECT Profit
ROUND(Duration, 0) AS RoundingtoWhole #this rounds the number to a whole number
ROUND(Duration, 0,1) AS Truncating #this truncates the number after the decimal point
FROM Income