尊龙凯时人生就是博

sqlÖеÄgroup byÓï¾äʲôÒâ˼

group by Óï¾äÓÃÓÚ½«Êý¾Ý°´Ö¸¶¨µÄÁлòÁÐ×éºÏ·Ö×é £¬²¢¶Ôÿ¸ö×éÖ´ÐоۺϺ¯Êý£¨ÈçÇóºÍ¡¢¼ÆÊý¡¢Çóƽ¾ùÖµ£©À´»ã×ÜÊý¾Ý¡£ÆäÓ﷨Ϊ£ºselect ÁÐ1, ÁÐ2, …from ±íÃûgroup by ·Ö×éÁÐ

SQL ÖÐµÄ GROUP BY Óï¾ä

GROUP BY Óï¾äÓÃÓÚ½«Êý¾Ý·Ö×é £¬²¢½«Ïàͬ×éÖеļͼ¾ÛºÏÔÚÒ»Æð¡£Í¨¹ý½«Êý¾Ý·ÖΪ²î±ðµÄ×é £¬Ëü¿ÉÒÔ×ÊÖúÎÒÃÇ»ã×ÜÐÅÏ¢¡¢Ê¶±ðģʽ²¢¼ò»¯Ð§¹û¡£

Óï·¨

SELECT ÁÐ1, ÁÐ2, ...
FROM ±íÃû
GROUP BY ·Ö×éÁÐ

µÇ¼ºó¸´ÖÆ

ÆäÖУº

ÁÐ1¡¢ÁÐ2¡¢… ÊÇÒª¼ìË÷µÄÁС£

±íÃû ÊÇÒª·Ö×éµÄ±í¡£

·Ö×éÁÐ ÊÇÒªÓÃÓÚ·Ö×éµÄÁлòÁеÄ×éºÏ¡£

¹¦Ð§

GROUP BY Óï¾äƾ֤ ·Ö×éÁÐ µÄÖµ½«Êý¾Ý·Ö×é £¬È»ºóÕë¶Ôÿ¸ö×éÖ´ÐоۺϺ¯Êý£¨Èç SUM()¡¢COUNT()¡¢AVG()£© £¬ÒÔ»ã×ÜÊý¾Ý¡£

ʾÀý

˼Á¿Ò»¸ö°üÀ¨Ñ§ÉúЧ¹ûµÄ±í£º

| ѧºÅ | ѧÉúÐÕÃû | ÊýѧЧ¹û | ÓïÎÄЧ¹û |
|---|---|---|---|
| 1 | ˔Ȼ | 90 | 85 |
| 2 | ÍõÇ¿ | 85 | 90 |
| 3 | ÀîÃ÷ | 95 | 80 |
| 4 | ÕÅΰ | 80 | 95 |

µÇ¼ºó¸´ÖÆ

ÈôÊÇÎÒÃÇÏ밴ѧÉúÐÕÃû·Ö×é²¢ÅÌËãÿλѧÉúµÄƽ¾ùÊýѧЧ¹û £¬¿ÉÒÔʹÓÃÒÔÏ GROUP BY Óï¾ä£º

SELECT ѧÉúÐÕÃû, AVG(ÊýѧЧ¹û) AS ƽ¾ùÊýѧЧ¹û
FROM ѧÉúЧ¹û±í
GROUP BY ѧÉúÐÕÃû

µÇ¼ºó¸´ÖÆ

Ч¹û½«ÊÇ£º

| ѧÉúÐÕÃû | ƽ¾ùÊýѧЧ¹û |
|---|---|
| ˔Ȼ | 87.5 |
| ÍõÇ¿ | 85.0 |
| ÀîÃ÷ | 87.5 |
| ÕÅΰ | 82.5 |

µÇ¼ºó¸´ÖÆ

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

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

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