Hide a column used in Order By

Solved
Malik2Livry Posted messages 3 Status Member -  
Malik2Livry Posted messages 3 Status Member -
Hello everyone,

I have a little technical issue that is slightly blocking me on a query in Oracle (via SQL Developer).

I have a database (TEST) that contains 4 columns:
A: Name
B: Arrival Date
C: First Name
D: Salary

I would like to extract this database sorted by arrival date (Order by Arrival Date) but I do not want this column to be extracted.

However, when I do:
Select A, C, D
From TEST
ORDER BY B

I get the following error message:
ORA-01791: this expression is not SELECTed
01791. 00000 - "not a SELECTed expression"
  • Cause:
  • Action:

Error at line 3

Of course, I do not want to use a subquery as it would make my processing heavier (in fact, my query already involves three nested queries and adding one for an 'order by' is a bit frustrating for me)

Thank you in advance :-)

Have a good day.
Malik

1 answer

  1. jordane45 Posted messages 30427 Registration date   Status Moderator Last intervention   4 832
     
    Hello,

    And with a sub-select?
     SELECT A,C,D FROM( SELECT A, C, D,B FROM TEST ORDER BY B )T 


    --
    Best regards,
    Jordane
    0
    1. Malik2Livry Posted messages 3 Status Member
       
      Yes, this solution works. But I would like to avoid the subselect.

      Is there no function to hide a column?

      Thank you for your feedback anyway.
      0
    2. jordane45 Posted messages 30427 Registration date   Status Moderator Last intervention   4 832
       
      No.. Not in a "request" in any case... (nor in sqlDeveloper)
      After that, it's in the processing that you can or cannot take it into account... but that's in the "programming" part (Java, php......) that you manage it.
      0
    3. Malik2Livry Posted messages 3 Status Member
       
      Ouch, okay

      Too bad.

      Thank you for your help!
      0