Apologize in advance if this has been answered already as I couldn't find what I'm looking for.
I would like to have a table of part numbers with attributes such that I can join a part master table to this attribute table to get a list of valid attributes for each part in the part master. The attributes will vary for different part numbers depending on product line. For example, part number ABC might have attribute names OD, ID and Width while part number XYZ might only have Color and Length. The records would look something like this:
ABC, OD, 10.125
ABC, ID, 8.125
ABC, WIDTH, 6.500
XYZ, COLOR, Blue
XYZ, LENGTH, 16.375
No problem there. What I want to do next is pivot the records so that I can create specification sheets for like products (by product line). The tables by product line would have the attribute name for the field name. For example, part ABC is in the product group "Round Widgets" and part XYZ is under product group "Long Widgets". The query table for round widgets would have fields PN, OD, ID, and WIDTH while the query table for Long Widgets would have fields PN, COLOR and LENGTH. Each of the field names would be the attribute name from the table described above and the part number and attribute values would be the record data.
For pivoted table fields PN, OD, ID, and WIDTH the data would look like this:
ABC, 10.125, 8.125, 6.500
I've seen many examples of using PIVOT but they generally hard code the fields needed. The query that would feed this pivot would already be filtered by product group so that each part number in the query should have the same number of fields to pivot.
Thanks in advance for any help...
Aucun commentaire:
Enregistrer un commentaire