SQL Advanced Operations

Source: Internet
Author: User
Retrieve records from the Table from entry m to entry n: (Not In version)
Select top n-m + 1 *
FROM Table
WHERE (id not in (select top M-1 id FROM Table ))

Retrieve records m to n from the TABLE (Exists Version)

Select top n-m + 1 * from table as a WHERE Not Exists
(Select * From (Select Top m-1 * From TABLE order by id) B Where B. id = a. id)
Order by id

M is the superscript and n is the subscript. For example, 8th to 12 records are retrieved, m = 8, n = 12, and Table is the Table name.

Select Top n-m + 1 * From Table
Where Id> (Select Max (Id) From
(Select Top M-1 Id From Table Order By Id Asc) Temp)
Order By Id Asc

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.