mysqlÖеÄroundº¯ÊýÊÇʲôº¯Êý
mysql ÖÐµÄ round º¯ÊýÓÃÓÚ¶ÔÊý×Ö¾ÙÐÐËÄÉáÎåÈ룬Ó﷨Ϊ round(number, decimal_places)£¬ÆäÖÐ number ΪҪÉáÈëµÄÊý×Ö£¬decimal_places ΪÉáÈëºó±£´æµÄСÊýλÊý£¬Èç round(123.456, 2) ·µ»ØËÄÉáÎåÈ뵽СÊýµãºóÁ½Î»µÄÊý×Ö 123.46¡£
MySQL ÖÐµÄ ROUND º¯Êý
ROUND º¯ÊýÊÇÒ»¸öÓÃÓÚ¶ÔÊý×Ö¾ÙÐÐËÄÉáÎåÈëµÄº¯Êý¡£ËüÐèÒªÁ½¸ö²ÎÊý£º
Êý×Ö£ºÒªÉáÈëµÄÊý×Ö¡£
СÊýλÊý£ºÉáÈëºó±£´æµÄСÊýλÊý¡£
Óï·¨£º
ROUND(number, decimal_places)
µÇ¼ºó¸´ÖÆ
·µ»ØÖµ£º
ROUND º¯Êý·µ»ØÉáÈëºóµÄÊý×Ö¡£
Ó÷¨£º
ROUND º¯Êý³£ÓÃÓÚ¶ÔÇ®±ÒÖµ»òÆäËûÐèÒªÉáÈëµÄÊý×Ö¾ÙÐÐÃûÌû¯¡£ÀýÈ磺
SELECT ROUND(123.456, 2);
µÇ¼ºó¸´ÖÆ
Õ⽫·µ»ØËÄÉáÎåÈ뵽СÊýµãºóÁ½Î»µÄÊý×Ö£º123.46¡£
ʾÀý£º
ϱíչʾÁ˲î±ðÊý×ÖºÍСÊýλÊýµÄ ROUND º¯ÊýЧ¹û£º
Êý×Ö | СÊýλÊý | Ч¹û |
---|---|---|
123.456 | 0 | 123 |
123.456 | 1 | 123.5 |
123.456 | 2 | 123.46 |
123.456 | 3 | 123.456 |
×¢ÖØÊÂÏ
ÈôÊÇСÊýλÊýΪ¸ºÊý£¬ROUND º¯Êý½«ÉáÈëµ½ÕûÊýλ¡£
ÈôÊÇСÊýλÊýΪ 0£¬ROUND º¯Êý½«ËÄÉáÎåÈëµ½×î¿¿½üµÄÕûÊý¡£
ÒÔÉϾÍÊÇmysqlÖеÄroundº¯ÊýÊÇʲôº¯ÊýµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡