I need to rollup a bunch of detail records to a single line report like a groupby sum() rollup using data rather than numbers and I would like to do it with sql rather than in my
vb code.
Its basically a bunch of detail attributes of a product that I would like to generate a query returning one line per product based on a predefined set of attributes.
The data only has 3 columns:
codename = the product code
recordtype = the type of attribute
(for example price,weight,height,width,lastshipment)
data = the data value of the attribute
Sample data would be like this:
CODE1,PRICE,d1
CODE1,WEIGHT,d2
CODE1,HEIGHT,d3
CODE1,WIDTH,d4
CODE1,LASTSHIP,1/1/2004
CODE2,HEIGHT,d6
CODE3,PRICE,d7
CODE3,HEIGHT,d8
CODE3,WIDTH,d9
Output columns should look like this:
Code, Price, Weight, Height, Width
The output data from the sample above should look like this:CODE1,d1,d2,d3,d5
CODE2,null,null,d6,null
CODE3,d7,null,d8,d9
note in CODE1 I have a LASTSHIP type and I dont care about it, I just want the 4 types for this query.
I am using MSSQL 2000.
I am wide open to a better way to do this, I just need the ability to assign an unlimited number of attributes to a specific product and this was how I best figured out how to accomplish it giving the flexibility of any type of record.
Hope thats clearer...?
Thanks for your help!