mysqlÖÐavgʲôÒâ˼
ÔÚ mysql ÖУ¬avg º¯ÊýÅÌËãÒ»×éÊý×ÖÖµµÄƽ¾ùÖµ¡£ÆäÓ﷨Ϊ avg(expression)£¬ÆäÖÐ expression ÊÇÒªÅÌËãƽ¾ùÖµµÄÊý×Ö±í´ïʽ¡£Ëü¿ÉÒÔÓÃÓÚÅÌËãƽ¾ù¼ÛÇ®¡¢Æ½¾ù·ÖÊý¡¢Æ½¾ùÊýÄ¿µÈ¡£
AVG º¯ÊýÔÚ MySQL ÖеļÄÒå
ÔÚ MySQL ÖУ¬AVG º¯ÊýÊÇÒ»Ö־ۺϺ¯Êý£¬ÓÃÓÚÅÌËãÒ»×éÊý×ÖÖµµÄƽ¾ùÖµ¡£Ëü½«Ò»×éÊý×ÖÖµÏà¼Ó£¬È»ºó³ýÒÔÊý×ÖÖµµÄ¸öÊý£¬»ñµÃËüÃǵÄƽ¾ùÖµ¡£
Óï·¨
AVG º¯ÊýµÄÓï·¨ÈçÏ£º
AVG(expression)
µÇ¼ºó¸´ÖÆ
ÆäÖУº
expression ÊÇÒªÅÌËãƽ¾ùÖµµÄÒ»¸ö»ò¶à¸öÊý×Ö±í´ïʽ¡£
Ó÷¨
AVG º¯Êý¿ÉÒÔÓÃÓÚ¶àÖÖÇéÐΣ¬°üÀ¨£º
ÅÌËãÒ»×éÏúÊۼͼµÄƽ¾ù¼ÛÇ®
ÅÌËãÒ»×éѧÉúЧ¹ûµÄƽ¾ù·Ö
ÅÌËãÒ»×鶩µ¥µÄƽ¾ùÊýÄ¿
ʾÀý
ÒÔÏÂʾÀýÅÌËãÏúÊۼͼÖÐËùÓж©µ¥µÄƽ¾ù¼ÛÇ®£º
SELECT AVG(price) FROM sales_orders;
µÇ¼ºó¸´ÖÆ
Ч¹û
AVG º¯Êý½«·µ»Ø¸Ã±íÖÐËùÓж©µ¥¼ÛÇ®µÄƽ¾ùÖµ£¬ÀýÈç 100.00¡£
ÒÔÉϾÍÊÇmysqlÖÐavgʲôÒâ˼µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡