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(10.111,2) ROUND_TO;
--> 10.11
SELECT ROUND(10.101,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.123,2) ROUND_TO;
--> 500.12
SELECT ROUND(500.123) ROUND_TO;
--> 500
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(10.111,2) ROUND_TO;
--> 10.11
SELECT ROUND(10.101,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.123,2) ROUND_TO;
--> 500.12
SELECT ROUND(500.123) ROUND_TO;
--> 500
No comments:
Post a Comment