Using buildin function in user-defined function
mysql>
mysql> DELIMITER //
mysql>
mysql> CREATE FUNCTION myFunction (item_sum DECIMAL(10,2))
-> RETURNS DECIMAL(10,1)
-> BEGIN
->
->
-> RETURN ROUND(item_sum,1);
->
-> END
-> //
Query OK, 0 rows affected (0.00 sec)
mysql> DELIMITER ;
mysql>
mysql> select myFunction(123.12);
+--------------------+
| myFunction(123.12) |
+--------------------+
| 123.1 |
+--------------------+
1 row in set (0.02 sec)
mysql>
mysql> drop function myFunction;
Query OK, 0 rows affected (0.00 sec)
Related examples in the same category