469,890 Members | 2,158 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,890 developers. It's quick & easy.

Combining multiple records into one based on a key field -- inside one table !

I'm really scratching my head over this one. I'm working with CSV data exported
from Excel, which explains why it's a mess to begin with.

Within a table (or via any other means someone might be able to recommend) I
need to combine multiple records which share two like fields. (If that's not
clear, the real-world explanation is below.)

+----------+--------------+----+----+----+----+----+
| ID | ADDRESS | P1 | P2 | P3 | P4 | P5 |
+----------+--------------+----+----+----+----+----+
| COMP1 | 123 Main St | 1 | | | | |
| COMP1 | 123 Main St | | 1 | | | |
| COMP1 | 123 Main St | | | 1 | | |
| COMP2 | 45 Oak Pl | 1 | | | | |
| COMP2 | 45 Oak Pl | | | 1 | | |
| COMP2 | 45 Oak Pl | | | | 1 | |
| COMP2 | 45 Oak Pl | | | | | 1 |
+----------+--------------+----+----+----+----+----+

Must be distilled to :

+----------+--------------+----+----+----+----+----+
| ID | ADDRESS | P1 | P2 | P3 | P4 | P5 |
+----------+--------------+----+----+----+----+----+
| COMP1 | 123 Main St | 1 | 1 | 1 | | |
| COMP2 | 45 Oak Pl | 1 | | 1 | 1 | 1 |
+----------+--------------+----+----+----+----+----+

So essentially I want to combine all of the 'Px' fields for each ID into one
record.

The real model : The data represents companies (identified by ID) and the
product lines they stock (P1 - P5). Right now, there's a separate rec for each
product line. I need to combine those seperate recs into one.
____________________

I suppose I could import the raw data into separate tables, each with one 'P'
field -- and then combine them into another, but I'm not sure about that
approach either.
____________________

I already tried to make Excel combine before exporting, but had no luck.

Any help will be _greatly_ appreciated. I'm stumped.

Jul 20 '05 #1
0 924

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Christopher Harrison | last post: by
11 posts views Thread by dskillingstad | last post: by
4 posts views Thread by Robert Bravery | last post: by
2 posts views Thread by rdraider | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.