How to query the first few records of an Oracle table __oracle

Source: Internet
Author: User

As the project requires, look for the first few records in the Oracle table, oralcle by a rownum that can be used directly to get the required number of records, but the first SQL I used was: SELECT * from table where rownum< The number of records you want to check, although you can take out the first few records, but I found that if the sorting postscript to accept the first few results are not, that is, the SQL statement is as follows: SELECT * FROM table where rownum< the number of records you want to check by field name DESC, At run time, I found that: take out is not sorted by first after the first few, but first to remove the first several reorder , and I need to achieve the first sort and then take the first few, so select * FROM (SELECT * from the table order by field name Desc) w Here rownum< the number of records you want to check so that you can meet the criteria.

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.