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 table±íÓиöÎı¾ÀàÐ͵Äa×ֶΣ¬´æ´¢µÄÄÚÈÝÈ«²¿ÊÇÊý×Ö£¬ÀýÈç2009001£¬2008578ÕâÑùµÄ¸ñʽ£»b×Ö¶ÎÎı¾ÀàÐÍ£¬´æµÄÒ²ÊÇÊý×ÖÀýÈç 001£¬123
aspÀïÃæ strday=100£¬strb=001
ÎÒÏë¶Á³ö£¬´Óa×ֶεÄÊý×Ö°´´óµ½Ð¡µÄË ......
Êý¾ÝÀàÐÍ£º
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 ......
±íÖÐÊÇÕâÑù£¬
²¿ÃźŠ²¿ÃÅÐÅÏ¢
1 ²¿ÃÅÒ»
2 ²¿ÃŶþ
3 ²¿ÃÅÈý
4& ......
Çë°ïæ¿´¿´ÔõôÓÅ»¯Ò»Ï£¬¸Ã±íÊý¾ÝԼΪ66Íò£¬ÔËÐÐʱ¼äÒª19Ãë,SQLÈçÏ£º
select DATEPART (hh ,Date_time ) as Hours ,
sum(Counts)*100.0/(Select sum(Counts) as total
&nbs ......