The ROUND function in SQL is used to round a number to a specified precision. The syntax is:
ROUND (expression, [decimal place])
where [decimal place] indicates the number of decimal points returned. A negative number means the rounding will occur to the digit to the left of the decimal point. For example, -1 means the number will be rounded to the nearest tens.
Let's go through an example to see how the ROUND function is used. Let's assume we have the following table:
|Column Name||Data Type|
and this table contains the following rows:
SELECT First_Name, ROUND (Rating, 1) Rounded_Score FROM Student_Rating;
SELECT First_Name, ROUND(Rating, -1) Rounded_Score FROM Student_Rating;
Next: SQL CAST Function
|| Copyright © 2013 1keydata.com All Rights Reserved.