sqlÖÐroundº¯ÊýµÄʹÓÃÒªÁì
sql ÖÐ round º¯ÊýµÄʹÓÃ
ROUND º¯ÊýÔÚ SQL ÖÐÓÃÓÚ¶ÔÊý×Ö¾ÙÐÐÉáÈë¡£Ëü½ÓÊÜÁ½¸ö²ÎÊý£ºÒ»¸öÐèÒªÉáÈëµÄÊýÖµºÍÒ»¸öÉáÈëСÊýµãºóµÄλÊý¡£
ʹÓÃÒªÁ죺
ROUND(numeric_value, decimal_places)
µÇ¼ºó¸´ÖÆ
ÆäÖУº
numeric_value£ºÐèÒªÉáÈëµÄÊýÖµ¡£
decimal_places£ºÉáÈ뵽СÊýµãºóµÄλÊý¡£ÈôÊÇΪÕý£¬Ôò¾ÙÐÐËÄÉáÎåÈ룻ÈôÊÇΪ¸º£¬Ôò¾ÙÐнضϡ£
ʾÀý£º
-- ÉáÈ뵽СÊýµãºóÁ½Î»£¬ËÄÉáÎåÈë SELECT ROUND(123.456, 2); -- ÉáÈëµ½ÕûÊý£¬½Ø¶ÏСÊý²¿·Ö SELECT ROUND(123.456, 0); -- ÉáÈ뵽СÊýµãºóһ룬ÏòżÊýÉáÈë SELECT ROUND(123.5, 1);
µÇ¼ºó¸´ÖÆ
Ч¹û£º
123.46 123 124
µÇ¼ºó¸´ÖÆ
×¢ÖØÊÂÏ
ROUND º¯Êý·µ»ØÒ»¸öÓëÊäÈëÖµÀàÐÍÏàͬµÄÊýÖµ¡£
ÈôÊÇ decimal_places Ϊ 0£¬Ôò ROUND º¯Êý½«ÉáÈëµ½ÕûÊý¡£
ÈôÊÇ decimal_places Ϊ¸º£¬Ôò ROUND º¯Êý½«½Ø¶ÏСÊý²¿·Ö£¬¶ø²»»á¾ÙÐÐËÄÉáÎåÈë¡£
ROUND º¯Êý²»»áÐÞ¸ÄÔʼֵ£¬¶øÊÇ·µ»ØÒ»¸öеÄÉáÈëÖµ¡£
ÒÔÉϾÍÊÇsqlÖÐroundº¯ÊýµÄʹÓÃÒªÁìµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡
ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí£¬°æȨÕùÒéÓë±¾Õ¾Î޹أ¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í尊龙凯时人生就是博ÂËÓÍ»úÍø¹Ù·½Ì¬¶È£¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ£¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢£¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢£¬ÇëÄúÁ¬Ã¦ÁªÏµ尊龙凯时人生就是博ʵʱÐÞÕý»òɾ³ý¡£