troubleshooting Question

Ordering query results

Avatar of gram77
gram77Flag for India asked on
Oracle DatabaseDatabases
11 Comments2 Solutions371 ViewsLast Modified:
I have the following query.

Ordering the query gives me error:
ORA-01791: not a SELECTed expression

How do i order this query, first by colB, colC and ColA.

SELECT DISTINCT exch.colA  ||'|'|| hol.colB  ||'|'|| exch.colC
    FROM (  SELECT bc.colA,
              FROM tabA bc, tabB ex
             WHERE AND bc.colA IS NOT NULL
                   AND ex.colB = bc.colB
                   AND ex.colB IS NOT NULL
          GROUP BY bc.colA,
          ORDER BY bc.colA) exch,
         (SELECT *
            FROM tabA
           WHERE AND dt IS NOT NULL
                 AND dt >= TRUNC(TO_DATE ('09-JUL-10', 'dd-mon-yy'),'MONTH')
                 AND day_type = 'Myday') hol
   WHERE hol.colA = exch.colA
   ORDER BY exch.colA; <-- error on ordering
Join our community to see this answer!
Unlock 2 Answers and 11 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 11 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros