SQL takes the data method between two values (example: 100-200 data) _mssql

Source: Internet
Author: User
Data between 100 and 200 in table tables

Method 1: Temporary tables
Copy Code code as follows:

Select the * into #aa insert the top m pen into the temporary table by time--
SET ROWCOUNT 100
SELECT * FROM #aa desc

--drop Table #aa--Deleting temporary tables



Method 2:
Copy Code code as follows:

Select Top * FROM
(select top * from table order by time ASC)
ORDER BY Time Desc



Method 3:not in
Copy Code code as follows:

Select Top * from V_company where (
ID not in
(select Top ID from V_company ORDER by ID ASC)
) Order BY ID ASC



Here only 3 kinds of methods I tested, there are other options to be made up by the master, 3 of the efficiency of the program is not the same, I always think not in the efficiency is not good, but here with the fastest in the speed, please add the expert, thank you

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.