oracleÖÐroundº¯ÊýµÄÓ÷¨
oracle ÖÐµÄ round º¯Êý¿É½«Êý×ÖÉáÈëµ½Ö¸¶¨¾«¶È£¬Ó﷨Ϊ£ºround(number, decimals)¡£ÆäÖУ¬number ΪҪÉáÈëµÄÊý×Ö£¬decimals ΪÉáÈëµÄ¾«¶È¡£Ê¾Àý£º½« 123.456 ÉáÈ뵽СÊýµãºóһλ£ºround(123.456, 1)£»ÉáÈ뵽СÊýµãºóÁ½Î»£ºround(123.456, 2)£»ÉáÈëµ½ÕûÊý£ºround(123.456, 0)¡£
Oracle ÖÐµÄ ROUND º¯Êý
ROUND º¯ÊýÓÃÓÚ½«Êý×ÖÉáÈëµ½Ö¸¶¨µÄ¾«¶È¡£ËüÓÐÒÔÏÂÓï·¨£º
ROUND(number, decimals)
µÇ¼ºó¸´ÖÆ
ÆäÖУº
number ÊÇÒªÉáÈëµÄÊý×Ö¡£
decimals ÊÇÒªÉáÈëµ½µÄ¾«¶È¡£
ʹÓÃʾÀý
ÒÔÏÂÊÇ ROUND º¯ÊýµÄһЩʹÓÃʾÀý£º
½« 123.456 ÉáÈ뵽СÊýµãºóһλ£º
SELECT ROUND(123.456, 1) FROM dual;
µÇ¼ºó¸´ÖÆ
Êä³ö£º
123.5
µÇ¼ºó¸´ÖÆ
½« 123.456 ÉáÈ뵽СÊýµãºóÁ½Î»£º
SELECT ROUND(123.456, 2) FROM dual;
µÇ¼ºó¸´ÖÆ
Êä³ö£º
123.46
µÇ¼ºó¸´ÖÆ
½« 123.456 ÉáÈëµ½ÕûÊý£º
SELECT ROUND(123.456, 0) FROM dual;
µÇ¼ºó¸´ÖÆ
Êä³ö£º
123
µÇ¼ºó¸´ÖÆ
×¢ÖØÊÂÏî
ÈôÊÇ decimals ΪÕýÊý£¬Ôòº¯Êý½«Êý×ÖÉáÈ뵽СÊýµãºóÖ¸¶¨µÄСÊýλÊý¡£
ÈôÊÇ decimals Ϊ¸ºÊý£¬Ôòº¯Êý½«Êý×ÖÉáÈ뵽СÊýµãÇ°Ö¸¶¨µÄСÊýλÊý¡£
ÈôÊÇ decimals Ϊ 0£¬Ôòº¯Êý½«Êý×ÖÉáÈëµ½×î¿¿½üµÄÕûÊý¡£
ÈôÊÇ number Ϊ NULL£¬Ôòº¯Êý·µ»Ø NULL¡£
ÒÔÉϾÍÊÇoracleÖÐroundº¯ÊýµÄÓ÷¨µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡