尊龙凯时人生就是博

sqlÖÐsumʲôÒâ˼

sql ÖÐ sum µÄ¼ÄÒåÊÇÅÌËãÒ»×éÖµÖ®ºÍ£¬Ó﷨Ϊ sum(expression)¡£Ëü¿ÉÒÔÓ¦ÓÃÓÚÊý×ÖÁУ¬ºöÂÔ null Öµ£¬²¢¿ÉÓë group by ×Ó¾äÒ»ÆðʹÓã¬ÒÔÅÌËãÌض¨×éÖеÄÖµµÄ×ܺÍ¡£

SQL ÖÐ SUM µÄ¼ÄÒå

SUM ÊÇ SQL ÖÐÒ»¸ö¾ÛºÏº¯Êý£¬ÓÃÓÚÅÌËãÒ»×éÖµÖ®ºÍ¡£ËüµÄÓï·¨ÈçÏ£º

SUM(expression)

µÇ¼ºó¸´ÖÆ

ÆäÖÐ expression ÊÇÒªÅÌËãÆäºÍµÄÊýÖµ±í´ïʽ»òÁС£

Ó÷¨

SUM º¯Êý¿ÉÒÔÓ¦ÓÃÓÚÊý×ÖÁУ¬ÒÔ»ñµÃ¸ÃÁÐÖÐËùÓÐÖµµÄ×ܺÍ¡£ÀýÈ磺

SELECT SUM(salary) FROM employees;

µÇ¼ºó¸´ÖÆ

Õ⽫·µ»Ø employees ±íÖÐ salary ÁÐÖÐËùÓÐÖµµÄ×ܺÍ¡£

×¢ÖØÊÂÏî

SUM º¯ÊýºöÂÔ NULL Öµ¡£

ÈôÊÇ expression ÊÇÎı¾»òÈÕÆÚÀàÐÍ£¬SUM º¯Êý½«·µ»Ø NULL¡£

SUM º¯Êý¿ÉÒÔÓë GROUP BY ×Ó¾äÒ»ÆðʹÓã¬ÒÔÅÌËãÌض¨×éÖеÄÖµµÄ×ܺÍ¡£

ʾÀý

ÒÔÏÂʾÀýÑÝʾÔõÑùʹÓà SUM º¯ÊýÅÌËã²î±ð²¿·ÖµÄ×ÜÏúÊ۶

SELECT department, SUM(sales) AS total_sales
FROM sales
GROUP BY department;

µÇ¼ºó¸´ÖÆ

Õ⽫·µ»ØÒ»¸öЧ¹û¼¯£¬ÆäÖÐÿÐÐÏÔʾһ¸ö²¿·Ö¼°Æä×ÜÏúÊ۶

ÒÔÉϾÍÊÇsqlÖÐsumʲôÒâ˼µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

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