Question: retrieve data between 100 and 200 entries in a table
Method 1: temporary tableCopyCodeThe Code is as follows: Select top 200 * into # Aa from Table order by time -- Insert the top M pen into the temporary table
Set rowcount 100
Select * from # Aa order by time DESC
-- Drop table # Aa -- delete a temporary table
Method 2:Copy codeThe Code is as follows: Select Top 100 * from
(Select top 200 * from Table order by time ASC)
Order by time DESC
Method 3: not inCopy codeThe Code is as follows: Select Top 100 * From v_company where (
Id not in
(Select Top 100 ID from v_company order by id asc)
) Order by ID ASC
Here we only list three methods I tested. There are other solutions that can be supplemented by experts. The efficiency of the three solutions is not the same. I always think that not in is not efficient, however, using not in here is the fastest speed. Please explain it. Thank you.