SQL Group By Top ʵÏÖ
DECLARE @temp TABLE(
id INT,
[name] VARCHAR(50),
class VARCHAR(50)
)
INSERT INTO @temp
SELECT 1,'a','A'
UNION ALL SELECT 2,'b','C'
UNION ALL SELECT 3,'c','B'
UNION ALL SELECT 4,'d','C'
UNION ALL SELECT 5,'e','B'
UNION ALL SELECT 6,'f','A'
SELECT * from @temp AS _temp WHERE [name] IN
(
SELECT TOP 1 [name] from @temp WHERE _temp.class=class ORDER BY id DESC
)
ORDER BY class
Ïà¹ØÎĵµ£º
Ëø»úÖÆ
NOLOCKºÍREADPASTµÄÇø±ð¡£
1. ¿ªÆôÒ»¸öÊÂÎñÖ´ÐвåÈëÊý¾ÝµÄ²Ù×÷¡£
BEGIN TRAN t
INSERT INTO Customer
SELECT 'a','a'
2. Ö´ÐÐÒ»Ìõ²éѯÓï¾ä¡£
SELECT * from Customer WITH (NOLOCK)
½á¹ûÖÐÏÔʾ"a"ºÍ"a"¡£µ±1ÖÐÊÂÎñ»Ø¹öºó£¬ÄÇôa½«³ÉΪÔàÊý¾Ý¡£(×¢:1ÖеÄÊÂÎñδÌá½») ¡£NOLOCK±íÃ÷ûÓжÔÊý¾Ý±íÌí¼Ó¹²Ï ......
List<Class1> li = dc.Table_1.Where(item => item.id > 1).Cast<Class1>().ToList();
Table_1 Ϊ×Ô¶¯Éú³ÉÀà, class1Ϊ×Ô¶¨ÒåÀà,ÊôÐÔÃû³Æ¶¼ÊÇÒ»ÑùµÄ,ÒªÄÜʵÏÖÉÏÃæµÄÓï¾ä,±ØÐëÓм¸¸öÌõ¼þ
Table_1 ÐèÒª¼Ì³Ðclass1,¿ÉÒÔͨ¹ýpartialÀàÀ´ÊµÏÖ
Table_1 ÊôÐÔ¼Óoverride
class1ÀïÃæµÄÊôÐÔÒªÊÇvir ......
»ùÓÚË÷ÒýµÄSQLÓï¾äÓÅ»¯Ö®½µÁúÊ®°ËÕÆ
1 Ç°ÑÔ
¿Í·þÒµÎñÊܵ½SQLÓï¾äµÄÓ°Ïì·Ç³£´ó£¬ÔÚ¹æÄ£±È½Ï´óµÄ¾Öµã£¬ÍùÍùÒòΪһ¸öСµÄSQLÓï¾ä²»¹»ÓÅ»¯£¬µ¼ÖÂÊý¾Ý¿âÐÔÄܼ±¾çϽµ£¬Ð¡ÐÍ»úidleËùÊ£ÎÞ¼¸£¬Ó¦Ó÷þÎñÆ÷¶ÏÁ¬¡¢³¬Ê±£¬ÑÏÖØÓ°ÏìÒµÎñµÄÕý³£ÔËÐС£Òò´Ë£¬³ÆµÍЧµÄSQLÓï¾äΪ¿Í·þÒµÎñµÄ ......
On BULK COLLECT
By Steven Feuerstein Oracle ACE
Best practices for knowing your LIMIT and kicking %NOTFOUND
I have started using BULK COLLECT whenever I need to fetch large volumes of data. This has caused me some trouble with my DBA, however. He is complaining that although my programs mig ......