Favorites: Evenly click on a certain field to get an almost record

xiaoxiao2021-03-06  38

Http://community.9cbs.net/expert/topic/3752/3752955.xml?temp =.3692591 Create Record - Create Table T (ID Numeric, Class Varchar (50))

--delete tdeclare @i numeric set @ i = 0WHILE @i <5000begin set @ i = @ i 1insert Into t (id, class) VALUES (@ i, 'a') endwhile @i <10000begin set @ i = @ i 1INSERT INTO T (ID, Class) Values ​​(@ i, 'b') endwhile @i <15000begin set @ i = @ i 1insert Into T (ID, Class) Values ​​(@ i, 'c') End time 0 : 00: 06 Take six records method a select a. * From ta where a.id in (SELECT TOP 2 id from t where class = a.class order by id) 0:02:10 Method 2 Select * from t awhere (SELECT Count (1) from T where class = a.class and id <= a.id) BetWeen 1 and 2 0:00:30

转载请注明原文地址:https://www.9cbs.com/read-63311.html

New Post(0)