SELECT ROUND(4.589,3); // Ouput 4.589
SELECT ROUND(4.589,4); // Ouput 4.5890
SELECT ROUND(4.589,2); // Ouput 4.59
SELECT ROUND(4.589,1); // Ouput 4.6
SELECT ROUND(4.589); // Ouput 5
SELECT ROUND(-4.589); // Ouput -5
SELECT ROUND(-4.389); // Output -4
Syntax
ROUND(X,D); // X : Argument , D: Number of decimal places
SELECT ROUND(14.729,2); // Output is 14.73
Using negative value for Number of decimal places.
SELECT ROUND(234.96,-1); // Output is 230 SELECT ROUND(236.96,-1); // Output is 240 SELECT ROUND(3463.4896,-2); // Output is 3500Negative value for decimal place ( D) will affect left of decimal places.
SELECT name,percentage,round(percentage,0) as rnd FROM `student4`
Inside round function we can change the number of decimal places required to 1,2,3 etc .. here is an example.
SELECT name,percentage,round(percentage,2) as rnd FROM `student4`
Output is here
| name | percentage | rnd | |
|---|---|---|---|
| Max Ruin | 79.2982 | 79.30 | |
| Arnold | 59.6491 | 59.65 | |
| Krish Star | 63.1579 | 63.16 | |
| John Mike | 80.7018 | 80.70 | |
| Alex John | 78.9474 | 78.95 | |
| My John Rob | 72.9825 | 72.98 | |
| Asruid | 89.4737 | 89.47 | |
| Tes Qry | 72.9825 | 72.98 | |
| Big John | 52.6316 | 52.63 |
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.
| barbie | 22-11-2014 |
| what will be the value if negative round is asked? | |