puppet
IS-IT--Management
- Dec 13, 2001
- 140
I have a table with the following format:
Item Code_Type Code
---------------------
1 ABC H
1 DEF Q
1 GHI 20
25 ABC Y
25 DEF D
25 HGI 30
30 ABC L
30 DEF Q
30 GHI 25
30 GHI 45
And I want to create a flat table with the following format...
Item ABC DEF GHI
-------------------------
1 H Q 20
25 Y D 30
30 L Q 25
30 L Q 35
This would be simple if the Code_Type could only contain one value but at least one of the code types will sometimes (not always) contain multiple values - eg Code_Type GHI above has a value of 25 and 35. The actual data is different this was just an easier way to explain it.
I get table 1 from a dts package every morning and need to setup a job to create table 2 from table 1. I'm sure there must be an easy way to do this but I am still learning SQL and do not know how to do it.
Any ideas appreciated.
Item Code_Type Code
---------------------
1 ABC H
1 DEF Q
1 GHI 20
25 ABC Y
25 DEF D
25 HGI 30
30 ABC L
30 DEF Q
30 GHI 25
30 GHI 45
And I want to create a flat table with the following format...
Item ABC DEF GHI
-------------------------
1 H Q 20
25 Y D 30
30 L Q 25
30 L Q 35
This would be simple if the Code_Type could only contain one value but at least one of the code types will sometimes (not always) contain multiple values - eg Code_Type GHI above has a value of 25 and 35. The actual data is different this was just an easier way to explain it.
I get table 1 from a dts package every morning and need to setup a job to create table 2 from table 1. I'm sure there must be an easy way to do this but I am still learning SQL and do not know how to do it.
Any ideas appreciated.