plz help- query related to DB2

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shankarsunmicrosys
    New Member
    • Sep 2008
    • 3

    plz help- query related to DB2

    Hi,



    Could you please suggest, how to sort the data coming from a select query in DB2 UDB V8, without having order by clause?



    My query look like this:



    insert into <table1> select name, no from <table2> order by name. Because it’s not allowing to having order by in sub queries.





    Thanks in Advance.

    Shiva.
  • cburnett
    New Member
    • Aug 2007
    • 57

    #2
    Shiva,
    Presume you are using DB2 V8 as V9 supports insert into ... select ... from ... order by ....

    I have previously used:
    Code:
    insert into ... select  ... from ... group by ...
    successfully to simulate an order by in DB2 V8.

    Comment

    • docdiesel
      Recognized Expert Contributor
      • Aug 2007
      • 297

      #3
      Hi,

      user your SELECT including the ORDER BY statement to create a VIEW, and then insert into the destination table reading from there:

      Code:
      INSERT INTO
        DESTTABLE
      SELECT
        name, no
      FROM
        MYVIEW ;
      Regards

      Doc Diesel

      Comment

      • anijos
        New Member
        • Nov 2008
        • 52

        #4
        By what purpose is ORDER BY useful or valid on INSERT?
        Within an RDBMS one row has no inherent relationship to another row.

        AniJos

        Comment

        Working...