将“元”转换为“万元”、“亿元”
CREATE DEFINER=`root`@`localhost` FUNCTION `convert_money`(money float) RETURNS varchar(30) CHARSET utf8
BEGIN
#Routine body goes here...
declare result varchar(20);
set result = (case when ABS(money)<10000 then concat(convert(money,decimal(30,2)),'元')
when ABS(money)<100000000 then concat(convert(money/10000,decimal(30,2)),'万')
else concat(convert(money/100000000,decimal(30,2)),'亿') end);
RETURN result;
END
发表评论