mysqlÖÐroundʲôÒâ˼
round º¯ÊýÓÃÓÚ½«Êý×ÖËÄÉáÎåÈëµ½Ö¸¶¨Î»Êý£ºÓï·¨£ºround(number, decimals)£»decimals ΪÕýֵʱ£¬ËÄÉáÎåÈëµ½Ö¸¶¨Ð¡ÊýλÊý£»decimals Ϊ¸ºÖµÊ±£¬ËÄÉáÎåÈëµ½Ö¸¶¨ÕûÊýλ֮ǰ£»decimals Ϊ 0 ʱ£¬ÉáÈëµ½×î¿¿½üµÄÕûÊý£»number »ò decimals Ϊ null ʱ£¬·µ»Ø null¡£
ROUND º¯Êý
ROUND º¯ÊýÓÃÓÚ½«Êý×ÖËÄÉáÎåÈëµ½Ö¸¶¨µÄλÊý¡£
Óï·¨£º
ROUND(number, decimals)
µÇ¼ºó¸´ÖÆ
ÆäÖУº
number£ºÒªÉáÈëµÄÊý×Ö¡£
decimals£ºÖ¸¶¨ËÄÉáÎåÈëµ½µÄСÊýλÊý¡£
Àý×Ó£º
ROUND(123.456, 2) = 123.46
ROUND(3.14159, 3) = 3.142
ROUND(-25.789, 0) = -26
×¢ÖØ£º
ÈôÊÇ decimals ΪÕýÖµ£¬ÔòËÄÉáÎåÈ뵽СÊýµãºóÖ¸¶¨Î»Êý¡£
ÈôÊÇ decimals Ϊ¸ºÖµ£¬ÔòËÄÉáÎåÈëµ½Ö¸¶¨Î»Êý֮ǰµÄÕûÊýλ¡£
ÈôÊÇ decimals Ϊ 0£¬ÔòÉáÈëµ½×î¿¿½üµÄÕûÊý¡£
ÈôÊÇ number Ϊ NULL »ò decimals Ϊ NULL£¬Ôò·µ»Ø NULL¡£
ÒÔÉϾÍÊÇmysqlÖÐroundʲôÒâ˼µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡