尊龙凯时人生就是博

mysqlÖÐavgµÄÓ÷¨

mysql µÄ avg() º¯ÊýÓÃÓÚÅÌËãÊý×ÖÖµµÄƽ¾ùÖµ¡£ËüÖ§³Ö¶àÖÖÓ÷¨ £¬°üÀ¨£ºÅÌËãËùÓÐÏúÊÛ²úÆ·µÄƽ¾ùÊýÄ¿£ºselect avg(quantity_sold) from sales;ÅÌËã¼ÛÇ®µÄƽ¾ùÖµ£ºavg(price);ÅÌËãÏúÊÛ¶îµÄƽ¾ùÖµ£ºavg(quantity_sold * price)¡£avg() º¯ÊýºöÂÔ null Öµ £¬Ê¹Óà ifnull() ¿ÉÅÌËã·Ç¿ÕÖµµÄƽ¾ùÖµ¡£

MySQL ÖÐ AVG() º¯ÊýµÄÓ÷¨

AVG() º¯ÊýÓÃÓÚÅÌËãÒ»×éÊý×ÖÖµµÄƽ¾ùÖµ¡£ËüÊÇÒ»¸ö¾ÛºÏº¯Êý £¬ÕâÒâζ×ÅËü½«Ò»×éÐÐÖеÄÖµ»ã×ÜΪµ¥¸öЧ¹û¡£

Óï·¨£º

AVG(expression)

µÇ¼ºó¸´ÖÆ

ÆäÖУº

expression ÊÇÒªÅÌËãƽ¾ùÖµµÄÄ¿µÄÁлò±í´ïʽ¡£

Ó÷¨Ê¾Àý£º

¼ÙÉèÎÒÃÇÓÐÒ»ÕÅÃûΪ “sales” µÄ±í £¬ÆäÖаüÀ¨ÒÔÏÂÁУº

id (Ö÷¼ü)

product_name

quantity_sold

price

ÒªÅÌËãËùÓÐÏúÊÛ²úÆ·µÄƽ¾ùÊýÄ¿ £¬ÎÒÃÇ¿ÉÒÔʹÓÃÒÔÏÂÅÌÎÊ£º

SELECT AVG(quantity_sold) FROM sales;

µÇ¼ºó¸´ÖÆ

Ч¹û½«ÊÇÒ»¸ö°üÀ¨Æ½¾ùÊýÄ¿ÖµµÄµ¥¸öÐС£

ÆäËûÓÃ;£º

AVG() º¯Êý»¹¿ÉÒÔÓÃÓÚÅÌËãÆäËûÀàÐ͵Äƽ¾ùÖµ £¬ÀýÈ磺

ƽ¾ù¼ÛÇ®£ºAVG(price)

ƽ¾ùÏúÊ۶AVG(quantity_sold * price)

×¢ÖØÊÂÏ

AVG() º¯ÊýºöÂÔ NULL Öµ¡£

ÈôÊÇ expression ÖÐÖ»°üÀ¨ NULL Öµ £¬Ôò AVG() º¯Êý½«·µ»Ø NULL¡£

ÒªÅÌËã·Ç¿ÕÖµµÄƽ¾ùÖµ £¬¿ÉÒÔʹÓà AVG(IFNULL(expression, 0))¡£

ÒÔÉϾÍÊÇmysqlÖÐavgµÄÓ÷¨µÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

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

13452372176

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

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

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