Truncating numbers
Since rounding can sometimes be misleading, i.e., $16.8 becomes $17 while $16.4 remains $16, you may want to truncate the values after the decimal instead of rounding them. When you truncate the numbers, both $16.8 and $16.4 remain $16. In this exercise, you will do just that, truncate the Cost
column to a whole number.
This exercise is part of the course
Intermediate SQL Server
Exercise instructions
Write a SQL query to truncate the values in the Cost
column to the nearest whole number.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
-- Truncate cost to whole number
SELECT Cost,
___ AS TruncateCost
FROM Shipments