ORA-01791: not an SELECTed expression

Source: Internet
Author: User

Oracle 9i Database, execute the following statement with an error "ORA-01791: not SELECTed expression": SELECT distinct t.name from Auth_employee t ORDER by t.auth_employee_i D ASC

Original: When the SELECT statement contains the DISTINCT keyword or an operator, the sort field must correspond to the field in the SELECT statement.

The online search is interpreted as follows: When you specify multiple columns in an order BY, the result is sorted first by the first column in the clause, then the second, and so on.

Column names that do not appear in Select are also available in the ORDER BY clause, as long as there is a row in the table. However, if the DISTINCT keyword appears in the SELECT clause, only the column names that appear, and if any operators are used in the SELECT clause, must be persisted in the ORDER BY clause to be identical to the expression in the SELECT clause, or an error occurs: "ORA-01791 : Not an SELECTed expression.

ORA-01791: not an SELECTed expression

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.