sql Óï¾ä
±íA
¿¨ºÅ ʱ¼ä
1 null
2 null
3 null
±íB
¿¨ºÅ ʱ¼ä
1 2008-1-6
1 2004-5-3
2 2005-5-6
3 2003-5-9
3 2001-2-3
ÎÊÌ⣺¸üР±íAÀïµÄ ÏàÓ¦¿¨ºÅµÄʱ¼äΪ ±íBÀïÏàÓ¦¿¨ºÅµÄ£¨×îС£©Ê±¼ä
ÕýÈ·µÄ½á¹û£º
1 2004-5-3£¨×îС£©
2 2005-5-6
3 2001-2-3£¨×îС£©
SQL code:
update a set
ʱ¼ä = b.ʱ¼ä
from tb1 as a
join tb2 as b
on a.¿¨ºÅ= b.¿¨ºÅ
where not exists(select * from tb2
where ¿¨ºÅ=b.¿¨ºÅ and ʱ¼ä> b.ʱ¼ä)
SQL code:
update t set ʱ¼ä=(select min(ʱ¼ä) from tb where ¿¨ºÅ=t.¿¨ºÅ) from ta t
SQL code
Code highlighting produced by
Ïà¹ØÎÊ´ð£º
´ó¼ÒºÃ£¬ÇëÎÊÔÚ±íMÖÐÓÐ×ֶΣºa b c d e
ÎÒÏë²é³öÆäÖÐÂú×ãÏÂÃæÈÎÒâÒ»ÏîµÄÊý¾Ý£¬1.×Ö¶Îa µÄÖµ²»ÊÇ ¡®Êé»ò±Ê»ò±¾¡¯ÖÐÈÎÒ»£¬2.aΪÊéµÄʱºò×Ö¶Îb,cÊÇ¿Õ;3.µ±aֵΪ±ÊµÄʱºòdÊÇ¿Õ;4.µ±aΪ±¾µÄʱºòb,d,e¶¼ÊÇ¿Õ;5.È ......
ÏÖÔÚÓÐÁ½¸öÒì¹¹µÄsql serverÊý¾Ý¿â,ÎÒÏ뽫µÚÒ»¸ö±íÖеÄÊý¾Ýµ¼Èëµ½µÚ¶þ¸ö±íÖÐ,×Ô¼ºÖ¸¶¨µ¼ÈëÊý¾ÝµÄ×Ö¶Î,ÈçºÎµ¼ÈëÊý¾ÝÄØ,´ó¼ÒÌÖÂÛÒ»ÏÂ?
dts¹¤¾ß
µ¼Èëµ¼³ö¹¤¾ß.
DD
¹þ¹þ£¬¹À¼ÆÕâλÊǵØQIOU¶¼Êܲ»Á˵Ä
Ö±½ÓÐ ......
ÊDz»ÊÇÖ»ÄÜÔÚÖ´Ðд洢¹ý³Ì֮ǰÌæ»»µôÃô¸Ð×Ö·ûÁË£¿
Ó¦¸ÃÊǵģ¬¿ÉÒÔÓÃÕýÔòÈ¥Ìæ»»
ÒýÓÃ
Ó¦¸ÃÊǵģ¬¿ÉÒÔÓÃÕýÔòÈ¥Ìæ»»
µÃ´ç½ø³ßµÄÎÊÏ£¬³ýÁËÌæ»»µ¥ÒýºÅ£¬»¹ÐèÒªÌæ»»ÄÄЩÄØ£¿Ð»Ð»~
C# code:
ÎÒ×Ô ......
±íÖÐÊÇÕâÑù£¬
²¿ÃźŠ²¿ÃÅÐÅÏ¢
1 ²¿ÃÅÒ»
2 ²¿ÃŶþ
3 ²¿ÃÅÈý
4& ......
ÏÈÀ´Ò»¸ö´íÎóÓï¾ä¡£¡£
select * from [aa] where a1 in (select max(a2),a1 from [aa] group by a1 )
ÎÒ´óÌåÒâ˼£¬
¶ÁÈ¡Ò»¸öͳ¼ÆϵͳÖÐ ²»Öظ´µÄ IP °´ÕÕ ×îºóʱ¼äÅÅÐò£¬²¢ÏÔʾ³öËùÓÐ×ֶΡ£¡ ......