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!

Adding pivot data to sql table

Status
Not open for further replies.

MsChelle

Programmer
Jul 11, 2002
54
US
Table 1:

Date, Time, ID, Value1, Value2,.....Value20

Table 2:

Date, Time, ID, SubID, Value1, Value2...

-These tables are updated every halfhour, 24 hours a day, 7 days a week.
-There will be 2-3,000+ new records coming in every halfhour for table 1, and 10-20,000 new records each halfhour for table 2.
-The number of columns in both table 1 and table 2 is currently fixed, but upon new software releases, will expand.
-There will be exactly ID in table 2 that matches one in table 1 every halfhour.
-There can be anywhere from 3 to 20 SubIDs for each ID. The amount varies with each ID, and could vary among IDs day to day.
[So there is a 1 to 1 relationship between the cellids, but a 1 to many with the subids]

What we would like to do is append the data from table 2 horizontally onto the end of table 1 (like a pivot table stuck at the end of it). So the results would be something like:

Date, Time, ID, Value1, Value2, Value3, SubID1, SubID2, ...SubID20

4/21/04, 12:000, 50100, 10003, 2424, 3521, 2352, 252666, 123, ....3252

(yes, all values are numeric, but no calculations are required within the table itself)

Can anyone help me?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top