Topic
2 replies Latest Post - ‏2012-01-17T03:14:45Z by SystemAdmin
SystemAdmin
SystemAdmin
1731 Posts
ACCEPTED ANSWER

Pinned topic Rows Order MisMatch in DB2

‏2011-10-12T19:43:45Z |
Hi,

Select A from TableA
Union all
Select B from TableB
Union all
Select C from TableC

Why my result is not showing in Proper Order.

How can I retain the order as I written like is should show
A
B
C

Please Let me know ,How can I Retain the order without using orderby.

Thanks
Abhi
Updated on 2012-01-17T03:14:45Z at 2012-01-17T03:14:45Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    1731 Posts
    ACCEPTED ANSWER

    Re: Rows Order MisMatch in DB2

    ‏2011-10-13T17:30:23Z  in response to SystemAdmin
    You can't. The only way to guarantee the order of the result set is to use ORDER BY.

    Andy
  • SystemAdmin
    SystemAdmin
    1731 Posts
    ACCEPTED ANSWER

    Re: Rows Order MisMatch in DB2

    ‏2012-01-17T03:14:45Z  in response to SystemAdmin
    try

    select 1 ordercol,* from a
    union all
    select 2, * from b
    union all
    select 3, * from c
    order by 1