View previous topic :: View next topic
|
Author |
Message |
VIGNRSH Warnings : 1 New User
Joined: 18 Mar 2007 Posts: 44 Location: New Jersey,USA
|
|
|
|
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 |
|
|
ykishor Currently Banned New User
Joined: 11 Aug 2007 Posts: 24 Location: my pc
|
|
Back to top |
|
|
aishwarya_20
New User
Joined: 19 Nov 2008 Posts: 57 Location: pune
|
|
|
|
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 |
|
|
VIGNRSH Warnings : 1 New User
Joined: 18 Mar 2007 Posts: 44 Location: New Jersey,USA
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
|