Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

sql·Ö×麯ÊýʹÓÃ


ת×Ô£ºhttp://book.csdn.net/bookfiles/235/10023510864.shtml
ÔÚʵ¼ÊSQLÓ¦ÓÃÖУ¬¾­³£ÐèÒª½øÐзÖ×é¾ÛºÏ£¬¼´½«²éѯ¶ÔÏó°´Ò»¶¨Ìõ¼þ·Ö×飬Ȼºó¶Ôÿһ¸ö×é½øÐоۺϷÖÎö¡£
GROUP BY×Ӿ䴴½¨·Ö×é
´´½¨·Ö×éÊÇͨ¹ýGROUP BY×Ó¾äʵÏֵġ£ÓëWHERE×Ӿ䲻ͬ£¬GROUP BY×Ó¾äÓÃÓÚ¹éÄÉÐÅÏ¢ÀàÐÍ£¬ÒÔ»ã×ÜÏà¹ØÊý¾Ý¡£¶øΪʲôҪʹÓÃGROUP BY×Ӿ䴴½¨·Ö×éÄØ£¿¿Éͨ¹ýÏÂÃæÕâ¸ö¼òµ¥Àý×ÓÀ´ËµÃ÷¡£
ʵÀý17 µ¥Ò»·Ö×éµÄ²éѯ
¼ÙÈçÒª´ÓTEACHER±íÖвéѯËùÓÐÄнÌʦµÄƽ¾ù¹¤×Ê£¬ÓÃÇ°Ãæ½éÉܵľۺϺ¯ÊýAVG(),ʵÏÖ´úÂëÈçÏ£º
SELECT AVG(SAL) AS boyavg_sal
from     TEACHER
WHERE   TSEX='ÄÐ'
ÔËÐнá¹ûÈçͼ8.18Ëùʾ¡£
ͼ8.18 TEACHER±íÖвéѯËùÓÐÄнÌʦµÄƽ¾ù¹¤×Ê
¶øÈç¹ûͬʱÐèÒª²éѯËùÓÐÅ®½ÌʦµÄƽ¾ù¹¤×Ê£¬¸ÃÈçºÎ´¦ÀíÄØ£¿ÏÔÈ»£¬²ÉÓÃÉÏÊö·½·¨Ö»ÄÜÔÚWHERE×Ó¾äÖиıä²éѯÌõ¼þ£¬ÖØвéѯ¡£¶øÈç¹ûÒªÔÚÒ»´Î²éѯÖУ¬Í¬Ê±µÃµ½¶þÕߵIJéѯ½á¹û£¬¾ÍÐèÒªÒÔÐÔ±ðΪ»ù×¼£¬½«±íÖеÄËùÓÐÊý¾Ý¼Ç¼·Ö×飬¼´ÄнÌʦ×éºÍÅ®½Ìʦ×飬²¢·Ö±ð¶ÔÁ½×éÊý¾Ý½øÐзÖÎö£¬¼´¼ÆË㹤×Ê£¨SALÁУ©µÄƽ¾ùÖµ¡£
ʵÏÖÉÏÊö¹¦ÄÜ£¬¾ÍÐèҪʹÓ÷Ö×é×Ó¾äGROUP BY¡£°üÀ¨GROUP BY×Ó¾äµÄ²éѯ¾Í³ÆΪ×éºÏ²éѯ¡£Óï·¨ÈçÏ¡£
SELECT                              column, SUM(column)
from             table
GROUP BY        column
˵Ã÷£ºGROUP BY×Ó¾äÒÀ¾ÝcolumnÁÐÀïµÄÊý¾Ý¶ÔÐнøÐзÖ×飬¼´¾ßÓÐÏàͬµÄÖµµÄÐб»»®ÎªÒ»×é¡£ËüÒ»°ãÓë¾ÛºÏº¯ÊýͬʱʹÓᣵ±È»£¬ÕâÀïµÄSUM()º¯ÊýÒ²¿ÉÒÔÊÇÆäËû¾ÛºÏº¯Êý¡£ËùÓеÄ×éºÏÁУ¨GROUP BY×Ó¾äÖÐÁгöµÄÁУ©±ØÐëÊÇÀ´×Ôfrom×Ó¾äÁгöµÄ±í£¬²»Äܸù¾Ýʵ¼ÊÖµ¡¢¾ÛºÏº¯Êý½á¹û»òÕßÆäËû±í´ïʽ¼ÆËãµÄÖµÀ´¶ÔÐзÖ×é¡£
ʵÀý18 GROUP BY×Ó¾ä·Ö×é²éѯ
´ÓTEACHER±íÖвéѯËùÓÐÄнÌʦµÄƽ¾ù¹¤×ʺÍËùÓÐÅ®½ÌʦµÄƽ¾ù¹¤×Ê£¬ÊµÏÖ´úÂëÈçÏ¡£
SELECT           TSEX+'½Ìʦ'AS TEACHER, AVG(SAL) AS avg_sal
from                              &nb


Ïà¹ØÎĵµ£º

SQL Server 2005 Ô¶³ÌÁ¬½Ó

SQL Server 2005 ¿ª·¢°æ²»ÔÊÐíÔ¶³ÌÁ¬½Ó¡£
¡¡¡¡ÒªÔÊÐíÔ¶³ÌÁ¬½ÓSQL Server 2005 ,ÐèÒªÍê³ÉÒÔϲ½Ö裺
•ÔÚSQLServer ʵÀýÉÏÆôÓÃÔ¶³ÌÁ¬½Ó¡£
•´ò¿ª·þÎñÆ÷ SQLBrowser ·þÎñ¡£
•ÅäÖ÷À»ðǽÒÔÔÊÐíSQLBrowser ·þÎñºÍSQLServer·þÎñÍøÂçͨÐÅ¡£
¡¡¡¡ÔÚSQLServer ʵÀýÉÏÆôÓÃÔ¶³ÌÁ¬½Ó
1.Ö¸Ïò“¿ªÊ¼->³ÌÐ ......

SQL ServerÊý¾Ý¿âʱ³öÏÖ¹ÂÁ¢Óû§È¨ÏÞÎÊÌâµÄ½â¾ö°ì

--×Ô¼ººÜÓÞ´ÀµÄ×ö·¨£¬ÒÔΪֱ½Óɾ³ýÊý¾Ý¿âÓû§Ãû£¬ÔÙ´Óд´½¨Óû§µÇ¼ÃûºÍÊý¾Ý¿âÓû§Ãû¡£
--×Ô¼ºÒÔΪ¿ÉÒÔÖ±½Ó´´½¨ÓëÖ®Ô­ÏÈÒ»ÑùµÄÊý¾Ý¿âµÇ¼Ãû¾Í¿ÉÒÔ
--µ«ÕâЩ²Ù×÷ÊDz»Æð×÷ÓõÄ
--Ô­Òò
--µ±Ó³Éä¹ÂÁ¢Óû§Ê±£¬Ö÷´ÓÊý¾Ý¿âÖеÄSID½«·ÖÅä¸ø¹ÂÁ¢Óû§£¬ËùÒÔÿ´ÎÒ»¸öÊý¾Ý¿â±¸¸½¼Ó»òÕß»¹Ô­Ê±£¬--SIDÔÚSQL Server µÇ¼ÃûºÍÊý¾Ý¿âÓû ......

SQL ServerÊý¾Ý¿âÊÂÎñÈÕÖ¾´æ´¢ÐòÁÐ

Èç¹ûÄãµÄÊý¾Ý¿âÔËÐÐÔÚÍêÕû»òÊÇÅúÁ¿ÈÕÖ¾»Ö¸´Ä£Ê½Ï£¬ÄÇôÄã¾ÍÐèҪʹÓÃ×÷Òµ(job)À´¶¨ÆÚ±¸·ÝÊÂÎñÈÕÖ¾£¬±£³ÖÄãµÄÊÂÎñÎļþ´óС´¦ÔÚÒ»¸ö¿É¹ÜÀíµÄ·¶Î§¡£µ±ÄãÐèÒª»¹Ô­ÊÂÎñÈÕ־ʱ£¬Äã¾ÍÐèÒª°´ÕÕ´´½¨ÊÂÎñÈÕÖ¾µÄ˳ÐòÀ´»Ö¸´ËüÃÇ¡£Äã¿ÉÒԲο¼´æÔÚmsdb..backupset±íÖеÄÐÅÏ¢À´È·¶¨»¹Ô­ÎļþµÄ˳Ðò£¬Ê¹ÓÃFirstLSNºÍLastLSNÁеÄÖµ×÷²Î¿¼¡£µ±Ä ......

MY SQL »¹ÊǺÜÇ¿´óµÄ¡£¡£¡£

֮ǰûÔõôÑо¿¹ýMySQLµÄÈÝÁ¿£¬ÓÉÓÚÏîÄ¿ÐèÒª£¬ÐèÒªÒ»¸öÃâ·ÑµÄ¿ÉÒÔÖ§³ÖǧÍòÌõÊý¾Ý¼¶ÒÔÉϵÄÊý¾Ý¿â£¬²é¿´ÏÂmysqlµÄÎĵµ£¬·¢ÏÂmysql»¹ÊǺÜÇ¿´óµÄ£¬¼Ç¼Ï£¬ºÇºÇ¡£Ô­ÎÄÈçÏ£º
MySQL 3.22ÏÞÖƵıí´óСΪ4GB¡£ÓÉÓÚÔÚMySQL 3.23ÖÐʹÓÃÁËMyISAM´æ´¢ÒýÇ棬×î´ó±í³ß´çÔö¼Óµ½ÁË65536TB£¨2567 –1×Ö½Ú£©¡£ÓÉÓÚÔÊÐíµÄ±í³ß´ç¸ü´ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ