尊龙凯时人生就是搏

sqlÖгý·¨±£´æСÊýÔõôËãµÄ

sql³ý·¨±£´æСÊýµÄÒªÁ죺ʹÓÃcast¡¢round»òtruncateº¯Êý¡£castº¯ÊýÇ¿ÖÆת»»ÊýÖµÀàÐÍÒÔ±£´æÌض¨¾«¶ÈºÍСÊýλÊý¡£roundº¯ÊýËÄÉáÎåÈ븡µãÊýЧ¹û¡£truncateº¯Êý½Ø¶Ï¸¡µãÊýЧ¹û¡£

SQL Öгý·¨±£´æСÊýµÄÅÌËãÒªÁì

ÔÚ SQL ÖУ¬³ý·¨²Ù×÷·ûÊÇб¸Ü£¨/£©£¬Ëü»á±¬·¢Ò»¸ö¸¡µãÊýЧ¹û¡£Ä¬ÈÏÇéÐÎÏ£¬¸¡µãÊýЧ¹û±£´æСÊýµãºó 15 λÊý×Ö¡£

±£´æСÊýµÄÒªÁì

ΪÁ˱£´æ¸ü¶à»ò¸üÉÙµÄСÊý룬¿ÉÒÔʹÓÃÒÔÏÂÒªÁ죺

CAST º¯Êý£º½«ÆäÓÃÓÚ±»³ýÊý»ò³ýÊýÒÔÇ¿ÖÆת»»Îª¾ßÓÐÌض¨¾«¶ÈºÍ±ÈÀýµÄÊý×ÖÀàÐÍ¡£ÀýÈ磺

SELECT CAST(numerator AS DECIMAL(10, 2)) / CAST(denominator AS DECIMAL(10, 2));

µÇ¼ºó¸´ÖÆ

ROUND º¯Êý£ºÓÃÓÚ¶Ô¸¡µãÊýЧ¹û¾ÙÐÐËÄÉáÎåÈë¡£ÀýÈ磺

SELECT ROUND(numerator / denominator, 2);

µÇ¼ºó¸´ÖÆ

TRUNCATE º¯Êý£ºÓÃÓڽضϸ¡µãÊýЧ¹û¡£ÀýÈ磺

SELECT TRUNCATE(numerator / denominator, 2);

µÇ¼ºó¸´ÖÆ

ʾÀý

˼Á¿ÒÔÏÂÅÌÎÊ£º

SELECT 10 / 3;

µÇ¼ºó¸´ÖÆ

ĬÈÏÇéÐÎÏ£¬¸ÃÅÌÎʻ᷵»Ø¸¡µãÊýЧ¹û 3.3333333333333335¡£

ÈôÊÇÒª±£´æÁ½Î»Ð¡Êý£¬¿ÉÒÔʹÓà CAST º¯Êý£º

SELECT CAST(10 AS DECIMAL(10, 2)) / CAST(3 AS DECIMAL(10, 2));

µÇ¼ºó¸´ÖÆ

¸ÃÅÌÎʻ᷵»Ø 3.33¡£

ÒÔÉϾÍÊÇsqlÖгý·¨±£´æСÊýÔõôËãµÄµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí£¬°æȨÕùÒéÓë±¾Õ¾Î޹أ¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í尊龙凯时人生就是搏ÂËÓÍ»úÍø¹Ù·½Ì¬¶È£¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ£¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢£¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢£¬ÇëÄúÁ¬Ã¦ÁªÏµ尊龙凯时人生就是搏ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ尊龙凯时人生就是搏

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎ壬9:30-18:30£¬½ÚãåÈÕÐÝÏ¢

QR code
sitemap¡¢ÍøÕ¾µØͼ