SQL PHP HTML ASP JavaScript articles and free scripts to download

round sql

We can get rounded data by using round sql query. Here is an example
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
We will use our student table and get the rounded data by using round query.

Percentage is a column name in our student table. Here we store the percentage value of each student mark. One of our student Max has got 79.2982 percentage. This number we can round off and display without any decimal value by using command like this.
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` 
Try with different values The sql dump of student4 table is here .
SQL dump of Student4 table here

Google+

Post Comment This is for short comments only. Use the forum for more discussions.
Name
Email( not to be displayed)Privacy Policy
1+2=This is to prevent automatic submission by spammers. Please enter the result of the sum as asked



Join Our Email List
Email:  
For Email Newsletters you can trust

HTML . MySQL. PHP. JavaScript. ASP. Photoshop. Articles. FORUM Contact us

©2000-2014 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer