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

Çë½Ì¸÷λ´ó¸çÒ»¸öSqlÎÊÌ⣬Äĸö°à¼¶µÄ½Ìʦ´ýÓö×î¸ß£¿

СµÜ×î½üÓöµ½Ò»¸öÎÊÌ⣬ҪÇóµÃ³öÄĸö°à¼¶µÄ½Ìʦ´ýÓö×î¸ß£¬°Ñͬһ¸ö°à¼¶µÄ½Ìʦ´ýÓöºÏ¼ÆÆðÀ´


°à¼¶±í                  ½Ìʦ±í

°à¼¶ID                ½ÌʦID
°à¼¶Ãû×Ö              °à¼¶ID
                      ½Ìʦ´ýÓö 


Ê×ÏÈÏëµ½µÄÊÇÓÃMAX£¨´ýÓö£©,µ«ÊÇÖ»Äܵóö´ýÓö×î¸ßµÄ½Ìʦ£¬ºóÏëһϣ¬ºÃÏñÖ»Óд洢¹ý³Ì²ÅÄÜ´¦Àí£¬¶øÇÒ´æ´¢¹ý³ÌÖл¹ÒªÑ­»·´¦Àí°à¼¶ÊýºÍ½ÌʦÊý£¬±È½ÏÂé·³¡£

×îºóÒªÇó°´ÕÕ´ýÓö×î¸ßµÄ°à¼¶ÅÅÐòÏÂÀ´¡£

²»ÖªµÀ¸÷λ´ó¸çÓÐûÓкõÄ˼·ºÍ·½·¨£¬×îºÃµÄÊÇÒ»¾äSql¾ÍÄÜÍê³ÉµÄ¡£ÈçÓдúÂë¸üºÃ£¬Ð»Ð»ÁË



select °à¼¶ID,sum(½Ìʦ´ýÓö)
from ½Ìʦ±í
group by °à¼¶ID
order by 2 desc

SQL code:
select °à¼¶Ãû×Ö,sum(½Ìʦ´ýÓö)
from ½Ìʦ±í ,°à¼¶±í
where ½Ìʦ±í.°à¼¶ID = °à¼¶±í.°à¼¶ID
group by °à¼¶Ãû×Ö
order by 2 desc


SQL code:
select m.* , avg(n.½Ìʦ´ýÓö) ½Ìʦ´ýÓö from °à¼¶±í m , ½Ìʦ±í n where m.°à¼¶ID = n.°à¼¶ID group by m.°à¼¶ID,°à¼¶Ãû×Ö order by ½Ìʦ´ýÓö desc


ÊÇÓÃavg°É?ƽ¾ù´ýÓö°É?

²»ÊÇÓÃsum.

SQL code
{


Ïà¹ØÎÊ´ð£º

ÇóSQL£¿

´ó¼ÒºÃ£¬ÇëÎÊÔÚ±íMÖÐÓÐ×ֶΣºa b c d e 
ÎÒÏë²é³öÆäÖÐÂú×ãÏÂÃæÈÎÒâÒ»ÏîµÄÊý¾Ý£¬1.×Ö¶Îa µÄÖµ²»ÊÇ ¡®Êé»ò±Ê»ò±¾¡¯ÖÐÈÎÒ»£¬2.aΪÊéµÄʱºò×Ö¶Îb,cÊÇ¿Õ;3.µ±aֵΪ±ÊµÄʱºòdÊÇ¿Õ;4.µ±aΪ±¾µÄʱºòb,d,e¶¼ÊÇ¿Õ;5.È ......

Á½¸öµ¼¹¹sql serverÊý¾Ý¿â,Êý¾Ýµ¼Èëµ¼³öÎÊÌâ

ÏÖÔÚÓÐÁ½¸öÒì¹¹µÄsql serverÊý¾Ý¿â,ÎÒÏ뽫µÚÒ»¸ö±íÖеÄÊý¾Ýµ¼Èëµ½µÚ¶þ¸ö±íÖÐ,×Ô¼ºÖ¸¶¨µ¼ÈëÊý¾ÝµÄ×Ö¶Î,ÈçºÎµ¼ÈëÊý¾ÝÄØ,´ó¼ÒÌÖÂÛÒ»ÏÂ?
dts¹¤¾ß

µ¼Èëµ¼³ö¹¤¾ß.

DD

¹þ¹þ£¬¹À¼ÆÕâλÊǵØQIOU¶¼Êܲ»Á˵Ä

Ö±½ÓÐ ......

SQL serverÊý¾Ý¼¯³ö´íÇóÖú

Á½ÖÖ´íÎó£º
1.Èç¹ûÎÒÕâÑùÉêÃ÷£ºResultSet rs;´íÎóÌáʾÈçÏ£º

An error occurred at line: 51 in the jsp file: /index.jsp
The local variable rs may not have been initialized
48:    ......

sqlÎļþ£¨Êý¾Ýº¬ÖÐÎÄ£©DOSÃüÁî´°¿ÚÎÞ·¨µ¼ÈëÎÊÌâ

ÎÒÓõÄÊÇmysql5.1£¬Êý¾Ý¿â×Ö·û¼¯Îªutf8

ͨ¹ýdosÃüÁîÐе¼ÈëSQLÎļþ ³ö´í£¬ÎÞ·¨µ¼Èë¡£

½«SQLÎļþÖеÄÊý¾ÝÈ«²¿Ê¹ÓÃÓ¢ÎÄ ¿ÉÒÔµ¼Èë

ÇëÎÊÎÊÌâÔÚÄÄ£¿
×°¸öÖÐÎÄÈí¼þ¼´¿É.

ºÜ¶àÄêÒÔÇ°,Óùý¸öÒ»¸ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ