Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

pivot data in a table?

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I am a new DB2 user. I am using DB2 UDB v7.

I need to create a second table from a table. Table 1 has multiple rows for each product in column 1 and non-numeric data in column 2. Table 2 needs to have 1 row for each distinct value in column 1 and be followed the first 10 values found from column 2. I have placed an example below.

I know this is not a traditional SQL problem. I would like to avoid writing a program with multiple SQL statements and non-sql logic.

Table 1

Prod# value
A a
A b
A c
A d
B a
B c
B d
B e

Table 2

Prod# val1 val2 val3 val4 val5 . . . . val10
A a b c d . . . . . . .
B a c d e . . . . . . .
[sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top