SQL½»²æ²é詢
data a b c d e tag
2009-11-01 11 0 1 11 21 0
2009-12-01 11 0 21 11 21 0
2010-01-01 0 2 2 1 11 0
2009-11-01 1 1 1 0 0 1
2009-12-01 2 3 0 0 0 1
2010-01-01 22 4 12 0 0 1
²é詢結¹û顯ʾ為£º
tag 2009-11-01 2009-12-01 2010-01-01
0 44 64 16
1 4 6 39
請¸ßÈËÖ¸點ÏÂ
ÐÐתÁÐ ÓÃsum
ËÑһϣ¬ÐÐתÁÐÀ϶àÁË
SQL code:
/*
±êÌ⣺ÆÕͨÐÐÁÐת»»(version 2.0)
×÷Õߣº°®Ð¾õÂÞ.ع»ª(Ê®°ËÄê·çÓê,ÊصñùɽѩÁ«»¨¿ª)
ʱ¼ä£º2008-03-09
µØµã£º¹ã¶«ÉîÛÚ
˵Ã÷£ºÆÕͨÐÐÁÐת»»(version 1.0)½öÕë¶Ôsql server 2000Ìṩ¾²Ì¬ºÍ¶¯Ì¬Ð´·¨£¬version 2.0Ôö¼Ósql server 2005µÄÓйØд·¨¡£
ÎÊÌ⣺¼ÙÉèÓÐÕÅѧÉú³É¼¨±í(tb)ÈçÏÂ:
ÐÕÃû ¿Î³Ì ·ÖÊý
ÕÅÈý ÓïÎÄ 74
ÕÅÈý Êýѧ 83
ÕÅÈý ÎïÀí 93
ÀîËÄ ÓïÎÄ 74
ÀîËÄ Êýѧ 84
ÀîËÄ ÎïÀí 94
Ïë±ä³É(µÃµ½ÈçϽá¹û)£º
ÐÕÃû ÓïÎÄ Êýѧ ÎïÀí
---- ---- ---- ----
ÀîËÄ 74 84 94
ÕÅÈý 74 83 93
-
Ïà¹ØÎÊ´ð£º
´ó¼ÒºÃ£¬ÇëÎÊÔÚ±íMÖÐÓÐ×ֶΣºa b c d e
ÎÒÏë²é³öÆäÖÐÂú×ãÏÂÃæÈÎÒâÒ»ÏîµÄÊý¾Ý£¬1.×Ö¶Îa µÄÖµ²»ÊÇ ¡®Êé»ò±Ê»ò±¾¡¯ÖÐÈÎÒ»£¬2.aΪÊéµÄʱºò×Ö¶Îb,cÊÇ¿Õ;3.µ±aֵΪ±ÊµÄʱºòdÊÇ¿Õ;4.µ±aΪ±¾µÄʱºòb,d,e¶¼ÊÇ¿Õ;5.È ......
ÎÒϵͳʽwin7 £¬Êý¾Ý¿âsqlserver2008.Ò»Ö±ÓÃwindowsÑéÖ¤£¬µÇ½£¬²»ÄÜÓÃsqlÑéÖ¤£¬ÔÚsaÉÏÖØÐÂ×¢²áÒ»¸öÓû§µÄ»°£¬µÇ½ʱµÚÒ»±é±¨
Òѳɹ¦Óë·þÎñÆ÷½¨Á¢Á¬½Ó£¬µ«ÊÇÔڵǼ¹ý³ÌÖз¢Éú´íÈ¡¡££¨provider:¹²ÏíÄÚ´æÌṩ³ÌÐò£¬ ......
ÓÐÒ»¸ö±í½á¹¹ÈçÏ£º
ÎïÆ·±àÂë ʹÓôÎÊý Ãû³Æ ÊôÐÔ1£¬ÊôÐÔ2.¡£¡£¡£¡£¡£¡£
ÆäÖУ¬Ç°Á½ÏîΪÖ÷¼ü£¨ÎïÆ·±àÂë ʹÓôÎÊý£©£¬´ÎÊý×î¶àΪ5
ÏÖÔÚÎÒÏë°Ñ ͬһÖÖÎïÆ·µÄ²»Í¬´ÎÊýµÄÊôÐ ......
http://topic.csdn.net/u/20091008/12/a2577eba-1b5b-4e1e-ab20-0a047bf3f8d7.html?4385
1Â¥
liangCK
SQL code:
update a set
ʱ¼ä = b.ʱ¼ä
from tb1 as a
join tb2 as b
on a.¿¨ºÅ= b.¿¨ ......
ÎÊÌâÃèÊö£º
ÎÒÓõÄÊÇsql 2000
ÆóÒµ¹ÜÀíÆ÷->Õ¹¿ª·þÎñÆ÷->¹ÜÀí->SQL Agent->ÊôÐÔ
ÔÚ´¦À´µÄSQL Server´úÀíÊôÐÔ¶Ô»°¿òÖÐ Óʼþ»á»°Ñ¡Ïî¿òÏÂÃæµÄ ÓʼþÅäÖÃÎļþ ²»ÄÜÓà ³ÊÏÖ»ÒÉ«
ÎÒͬѧµÄÈ´ÄÜÓᣠ......