IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Load the data into Table2 sorting by the first column


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
ssowmya

New User


Joined: 10 Oct 2006
Posts: 40

PostPosted: Wed Jan 24, 2007 4:57 pm
Reply with quote

Hi All

I have a table, say Table1 and it has no key and the records are also not sorted...I need to load the data into Table2 (similar structure) sorting by the first column. The query I use is

INSERT INTO TABLE2 SELECT * FROM TABLE1 ORDER BY COLUMN1

But when I do a SELECT * FROM TABLE2, the records are not sorted by COLUMN1. Please let me know where I am going wrong....

Thanks
Sowmya
Back to top
View user's profile Send private message
harish_mf

New User


Joined: 31 Jul 2005
Posts: 18
Location: bangalore

PostPosted: Wed Jan 24, 2007 5:18 pm
Reply with quote

Hi all,

I have a table like,

emp id joined month ......
1 feb
2 mar
3 june
4 jan
'' ....
like this including all the month, Now I want it to sort it by month.


Could you please guide me how to sort by month in DB2.

Thanks & Regards

Harish.B
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Jan 24, 2007 7:29 pm
Reply with quote

Hello,

In both cases, use an ORDER BY in the select that you need the rows returned in sequence. A select with NO "order by" says you do not need any particular sequence.
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Wed Jan 24, 2007 9:29 pm
Reply with quote

Harish.B,

can you please start a new post for your question? Also, What are the exact abbreviations fro the months?

Thanks,
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts How to save SYSLOG as text data via P... All Other Mainframe Topics 4
No new posts Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts Store the data for fixed length COBOL Programming 1
No new posts Load new table with Old unload - DB2 DB2 6
No new posts Data set Rec-Cnt and Byte-Cnt Testing & Performance 2
Search our Forums:

Back to Top