Sql²éѯÓï¾äÎÊÌâ - .NET¼¼Êõ / ASP.NET
±ít1
3¸ö×Ö¶ÎCompanyName Product EntryDate
°´ÕÕʱ¼äÅÅÐòÏÔʾǰ10ÌõÊý¾Ý¡£
µ«ÊÇ£¬Ã¿Ò»¼Ó¹«Ë¾ËùÏÔʾµÄ²úÆ·¼Ç¼²»Äܳ¬¹ý2Ìõ¡£
Ò²¾ÍÊÇ˵£¬ÓпÉÄÜÇ°Ãæ10ÌõÊý¾Ý¶¼ÊÇͬһ¼Ò¹«Ë¾µÄ¡£ÄDz»ÐУ¬±ØÐëÒ»¼Ó¹«Ë¾¡£×î¶àÖ»ÄÜ2Ìõ¡£
ÕâÊÇÎÒÃæÊÔÅöµ½µÄÒ»¸öÎÊÌâ¡£¿àÏëÁ˺ܾã¬Ò²Î´ÄÜÍ»ÆÆ¡£»¹Çë¸ßÊÖÃÇÖ¸½Ì¡£Ð»Ð»£¡
Çó¸ßÊÖ£¬×Ô¼º¶¥
Ò²¾ÍÊÇ˵ֻÏÔʾ5¼Ò¹«Ë¾ £¿ ¶øÇÒÊÇ5¼Ò¹«Ë¾ÀïµÄÐÅÏ¢×î¿¿Ç°µÄ2ÌõÊý¾Ý £¿£¿
Èç¹ûÊÇsql server 2005ÒÔÉÏ£¬¿ÉÒÔÓÃrank():
select top 10 t.CompanyName, t.Product, t.EntryDate
from (select CompanyName, Product, EntryDate , rank() as rank over (partition by CompanyName order by entrydate) from t1 order by entrydate) t where t.rank <= 2
ÓеãÄѶÈ~~~
select * from Tb a where CompanyName in (select top 2 CompanyName from Tb where id=a.id order by CompanyName)
ÓеãÂé·³!
Èç¹ûÊÇsql server 2000,ÊÔÊÔÕâ¸ö£º
select top 10 a.* from t1 a where (select count(*) from t1 b where a.CompanyName = b.CompanyName and a.EntryDate < b.EntryDate) <= 2
¸Äһϣº
select top 10 a.* from t1 a where (select count(*) from t1 b where a.CompanyName = b.CompanyName and a.EntryDate < b.EntryDate) <= 2 order by a.entrydate
ºÏÔÚÒ»Æð£º
sql server 2005ÒÔÉÏ£º
SQL code:
select top 10 t.CompanyName, t.Product, t.EntryDate
from (selec
Ïà¹ØÎÊ´ð£º
Ö´ÐеÄ˳Ðò£º
1£©Îļþä¯ÀÀ¿ò£¨Ñ¡ÔñÎļþʹÓã©
Ñ¡ÔñºÃÎļþºó
µã»÷Ò»¸öµ¼Èë°´Å¥µÄʱºò £¬°ÑÉÏÃæÉÏ´«¿òÀïµÄcsvÎļþÒÔÒ»¸öIDΪÎļþÃû£¬ÉÏ´«µ½**/**Îļþ¼ÐÏÂ
2£©¶ÁÈ¡Õâ¸öÎļþ¼ÐϵÄcsvµÄÎļþ£¬×ª»»³Ésql
3 ......
C# code:
SqlConnection conn = CsDB.sqlcon();
SqlDataAdapter da = new SqlDataAdapter("select fwCoding from bjmuma_fwCoding where OrderNumber='" + Order + & ......
±¾È˹¤×÷¾ÑéÒ»ÄêÒÔÉÏ
ÊìϤasp.net
ÊìϤjavascript
ÊìϤCss
ÊìϤajax
ÊìϤsqlserver2005
ÓÐÒ»ÄêµÄÏîÄ¿¾Ñé
¾ßÌåÏîÄ¿ºÍÆäËûµÄ¾Í²»ÔÚÕâдÁË
ÓÐÒâÕßÁªÏµ£º
QQ:359233910
ÒýÓÃ
±¾È˹¤×÷¾ÑéÒ»ÄêÒÔÉÏ
ÊìϤasp ......
ÕâÀïÏëÁ˽âÏ£¬¹ØÓÚSQL ServerÖзÖÒ³ºÍOracleÖзÖÒ³£»
ƽ³£Ð´Ó¦ÓóÌÐòµÄʱºò£¬±ÈÈçÓõÄÓïÑÔÊÇJava£¬ÓиöÁбíÒ³Ã棬ÐèÒª¶ÔÊý¾Ý·ÖÒ³ÏÔʾ£»
ÕâÀïÒª·ÖÒ³ÄѵÀ²»ÐèÒª½èÖúJava£¬¶øÖ±½ÓsqlÄÜÖªµÀ·ÖÒ³Âð£¬ÆðÂëÒ²Òª´«¸öÒ³Âë½ ......
½«Ò»¸ö²éѯÓï¾ä¸³¸øÒ»¸ö±äÁ¿£¬ÈçÏ£º
DECLARE @STR NVARCHAR(MAX)
SET @STR='SELECT * from SALE_PROD'
ÔõôÑù²ÅÄÜÖ´ÐÐËüÄØ£¿
Çë¸ßÊÖ£¬ÈÊÐÖ£¬ÏÀ½ã°ï°ïæ°¡
¶àл£¬¿ÉÒÔÀ²£¬¸ßÊÖ°¡
Ö±½ÓÖ´ÐоÍÐÐÁË
exec ......