Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Adding Rownum based on key in Colunmn!

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
VIGNRSH
Warnings : 1

New User


Joined: 18 Mar 2007
Posts: 44
Location: New Jersey,USA

PostPosted: Mon Feb 16, 2009 12:32 pm    Post subject: Adding Rownum based on key in Colunmn!
Reply with quote

Hi,
I have been asked by my deployment team to write a query for this requirement.
sample I/P table:
Col1: col2:
aaaa1111 value1
aaaa1111 value2
aaaa1222 value1
aaaa1333 value1
aaaa1333 value2
aaaa1333 value3
aaaa1333 value4

Here as observed the COL1 has duplicate values and the O/P format they require is:
Row COL1 COL2
1 aaaa1111 value1
2 aaaa1111 value2
1 aaaa1222 value1
1 aaaa1333 value1
2 aaaa1333 value2
3 aaaa1333 value3
4 aaaa1333 value4

I.e They want the row number column to change in correpsondence with the COL1 and restart the value if the COL1 value changes.

I tried them contacting for the exact requirement, and they are yet to provide any inputs on that and they are persisting to go ahead with the exisitng problem statement !!

Can you Help?
Back to top
View user's profile Send private message

ykishor
Currently Banned

New User


Joined: 11 Aug 2007
Posts: 24
Location: my pc

PostPosted: Wed Feb 18, 2009 2:15 pm    Post subject:
Reply with quote

I guess you require the O/P in a flat file. If yes, then unload the table to a dataset and use ICETOOL/DFSORT.

refer to the link below

http://www.ibmmainframes.com/about28396.html
Back to top
View user's profile Send private message
aishwarya_20

New User


Joined: 19 Nov 2008
Posts: 57
Location: pune

PostPosted: Wed Feb 18, 2009 2:21 pm    Post subject: Reply to: Adding Rownum based on key in Colunmn!
Reply with quote

Could you please expalin your problem. Do you want the ouput in the flat file or Row column is one of the columns in Table?
Back to top
View user's profile Send private message
VIGNRSH
Warnings : 1

New User


Joined: 18 Mar 2007
Posts: 44
Location: New Jersey,USA

PostPosted: Tue Feb 24, 2009 6:51 pm    Post subject:
Reply with quote

I want it as a column in the output, not inf the flat file.
The bsiness requirement is that ,
the column generated with the above seq numbers based on the key,
to be merged with other table in the join condition.
My seniors have asked me, to do only this part, and iam not sure of the other or actual requirement.

We are in db2 version 8.
So we cannotconsider using the row_number () function !
Back to top
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Tue Feb 24, 2009 10:39 pm    Post subject:
Reply with quote

Hello,

Quote:
I want it as a column in the output, not inf the flat file.
?
Quote:
to be merged with other table in the join condition.
What other table? I am probably mis-reading something, but i see only one table. I'm not sure where JOIN can be used for this.

Is this ROW column to be part of the/a key? Is the ROW column already defined in the table?

One easy way to generate the ROW value would be to be a programmer for a few minutes, declare a cursor ordering by COL1 COL2, fetch each row and generate the proper ROW value depending if a new 1 was needed or an increment to the existing value was needed.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm
No new posts Inserting records based on conditions vickey_dw DFSORT/ICETOOL 9 Wed Feb 22, 2017 1:33 pm
No new posts Removing Duplicates based on certain ... chandracdac DFSORT/ICETOOL 8 Fri Dec 09, 2016 4:40 am
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm
No new posts abend sort based on count records in ... anatol DFSORT/ICETOOL 5 Mon Oct 17, 2016 10:10 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us