SQL Óï¾ä¡£¡£ Çë½Ì¸ßÊÖ
ÏÈÀ´Ò»¸ö´íÎóÓï¾ä¡£¡£
select * from [aa] where a1 in (select max(a2),a1 from [aa] group by a1 )
ÎÒ´óÌåÒâ˼£¬
¶ÁÈ¡Ò»¸öͳ¼ÆϵͳÖÐ ²»Öظ´µÄ IP °´ÕÕ ×îºóʱ¼äÅÅÐò£¬²¢ÏÔʾ³öËùÓÐ×ֶΡ£¡£
¸ßÊÖÇë°ï°ï棬£¬ÒªÇóÒ»ÐÐÓï¾äÍê³É¡£¡£
SQL code:
select *
from [aa] t
where not exists(select 1 from [aa] where a1=t.a1 and a2>t.a2)
SQL code:
select * from [aa] a where a2 = (select max(a2) from [aa] where a1=a.a1 )
ÈýÂ¥Õý½â¡£¡£¡£
ÏÂÃæÓï¾äµ÷ÊÔͨ¹ý£º
select * from [aa] where a2 in (select max(a2) from [aa] group by a1)
²éѯ³ö ²»Öظ´µÄa1 °´ÕÕ a2 ×î´óÖµ×ÔÓÉ ASC »ò DESC
·Ç³£¸ÐлÁ½Î»¸ßÊÖÖ¸µã¡£¡£
ллл¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£
Ïà¹ØÎÊ´ð£º
ÏÖÔÚÓÐÁ½¸öÒì¹¹µÄsql serverÊý¾Ý¿â,ÎÒÏ뽫µÚÒ»¸ö±íÖеÄÊý¾Ýµ¼Èëµ½µÚ¶þ¸ö±íÖÐ,×Ô¼ºÖ¸¶¨µ¼ÈëÊý¾ÝµÄ×Ö¶Î,ÈçºÎµ¼ÈëÊý¾ÝÄØ,´ó¼ÒÌÖÂÛÒ»ÏÂ?
dts¹¤¾ß
µ¼Èëµ¼³ö¹¤¾ß.
DD
¹þ¹þ£¬¹À¼ÆÕâλÊǵØQIOU¶¼Êܲ»Á˵Ä
Ö±½ÓÐ ......
Êý¾ÝÀàÐÍ£º
Code char(6)
CreateTime datetime
Price float
Êý¾ÝÈçÏ£º
Code CreateTime Price
031002 2008-10-17 15:00:15 ......
Êý¾ÝÀàÐÍ£º
Code char(6)
CreateTime datetime
Price float
Êý¾ÝÈçÏ£º
Code CreateTime Price
031021 2008-10-17 15:00:1 ......
ÓÐÁ½ÕÅ×Ö¶ÎÏàͬµÄ±íA£¬B¡£×Ö¶ÎΪSN, Name, Operator, Result, Remark
A±íÖÐ×Ö¶ÎSNΨһ£¬B±íÖÐ×Ö¶ÎSN²»Î¨Ò»£¬ÓкܶàÌõ
ÈçºÎÓÃÒ»ÌõselectÓï¾ä
°Ñ·ûºÏSN=¡¯abc¡¯µÄ¼Ç¼´ÓA£¬B±íÖÐɸѡ³öÀ´£¿
SQL co ......
ÒªÊäÈëUSE <Êý¾Ý¿âÃû>ʱ£¬ÒªÓõ½SQL±à¼Æ÷£¬µ«²»ÖªµÀÔÚʲôµØ·½£¬¸ßÊÖ°ï°ïæѽ£¡
SQL2005 µã»÷ÓÒÉϽǵÄ--н¨²éѯ(N)
Êó標選擇Òª²é詢µÄ數據庫£¬È»á ......