Error in Oracle 10g while adding Order by clause

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • 28490
    New Member
    • Dec 2006
    • 1

    Error in Oracle 10g while adding Order by clause

    Hi,

    In 10.2 when a query is run with GROUP BY it does not order the output by the grouped columns. In
    earlier versions the output was always sorted by the the grouped columns even though there was no
    ORDER BY clause present.

    [Oracle Version --Oracle 10.2.0.1.0]

    In order to get an ordered output,decided to add ORCDER BY clause explicitly.
    But gave ORA-00904: invalid column name error for following query.

    select max(acc_seq) from tbrc1wb
    group by br_cd,rc_base,f r_bk_ind,bdl_ac c
    union
    select max(acc_seq) from tbrc1mb
    group by br_cd,rc_base,f r_bk_ind,bdl_ac c
    order by br_cd,rc_base,f r_bk_ind,bdl_ac c


    Please suggest how to add ORDER BY clause in the above query.
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    It never happens that Oracle sorts records automatically with our ORDER BY clause.

    It might be data in your test table is already stored in sorted order.

    Comment

    Working...