troubleshooting Question

Ordering query results

Avatar of gram77
gram77Flag for India asked on
DatabasesOracle Database
11 Comments1 Solution371 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,
                   bc.colB,
                   ex.colC,
              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,
                   bc.colB,
                   ex.colC,
          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 the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 11 Comments.
Join the Community
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 1 Answer 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