SQL statement Nesting order BY is not valid

Source: Internet
Author: User

Selec * FROM (select top to Concentrator ORDER by ordinal ASC) Order BY ordinal desc) Order by ordinal ASC


The basic idea of this code is to search the first 100 rows in the table, and then put the 100 rows in reverse order to get 第81-100 rows of data, but at this point is reversed, and then the result in ascending order, the result indicates that this statement is invalid

(solution)
select  * from     ( SELECT TOP 20                      *            FROM       (  select top 100                                   *                        FROM      Concentrator                         ORDER BY   Serial Number  ASC                      )  a            order by   serial number  DESC         )  a order  BY  Serial  ASC

To add an alias

SQL statement Nesting order BY is not valid

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.