Resolution of "Ora-01791 not selected expression" error message appearing in Oracle queries

Source: Internet
Author: User

I write a sales query function module, but in the test when the bar code/code/warehouse conditions sorted by the time there is no error, as long as the date of the search will have "Ora-01791 is not selected expression" error message, and then view my SQL statements, statements are as follows:

Select distinct goodsid,barcode,depotid,goodsname from Sa_sale where depotid= ' one ' ORDER by selldate

There are errors in the execution of this sentence, but there are no errors when you change the sort to order by Goodsid or other barcode,depotid,goodsname, because Selldate is not in the query result field, And this statement is a distinct statement. So there's this error.

The correct solution is given below:

Select Goodsid,barcode,depotid,goodsname from

(Select distinct goodsid,barcode,depotid,goodsname,selldate from Sa_sale where depotid= ' 11 ')

ORDER BY Selldate

Problem solving, oh, take it to write in my blog, make a record. Also hope to help everyone.

Related Article

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.