Welcome to plsql4all.blogspot.com SQL, MYSQL, ORACLE, TERADATA, MONGODB, MARIADB, GREENPLUM, DB2, POSTGRESQL.

Saturday, 6 September 2014

ROUND function in MySql

ROUND function is used to round the number of decimal places. ROUND function takes two parameters,
one is the number to round and second is the number of decimal it should round to.

You must provide second parameter otherwise it will round the number to 0 decimal.

Syntax is:-

ROUND(NUMERIC_FIELD,[ROUND_NUMBER_TO_DECIMAL]);

Example:-

SELECT ROUND(20.123,2) ROUND_TO;

--> 10.12

SELECT ROUND(20.1023,2) ROUND_TO;

--> 10.1

Note:- Above it have rounded to number to two decimal but since the 0 is second decimal so it will skip the same.

SELECT ROUND(500.456,2) ROUND_TO;

--> 500.45

SELECT ROUND(500.6564) ROUND_TO;

--> 500




Read Also:- ROUND function in MariaDB

No comments:

Post a Comment

Please provide your feedback in the comments section above. Please don't forget to follow.