Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
vmon
Yak Posting Veteran
63 Posts |
Posted - 2007-08-13 : 14:46:27
|
| I have a scenario that reminds me of a pivot table and I am wondering if there is a way to handle this in SQL. I have four tables. Product Line, Item, Property, and Value. A Product Line has many items and an item can have many property's and a property can have many values. I want to select a product line and show all the items with the Property's as column headers and the Values as the data. The thing I am having trouble with is the property's for an item are variable from a few to a whole bunch.Any help would be appreciated.Thanks,vmon |
|
|
ashley.sql
Constraint Violating Yak Guru
299 Posts |
Posted - 2007-08-13 : 14:52:25
|
| can you post some sort of data, better yet include sql to create tables and a few inserts for the tables and then the required result. you can do it for just one product like.Ashley Rhodes |
 |
|
|
vmon
Yak Posting Veteran
63 Posts |
Posted - 2007-08-13 : 15:26:07
|
| Here is some of the data.ProductLine ProductLineDescrBlanks BlanksColPosts Columns and Posts ProductsDecAcces Decorative Accessories ProductsDisplays Sales DisplaysProductLine PropertyIdColPosts DiamenterColPosts Length ColPosts Type ColPosts Special ColPosts Group DecAcces Thickness DecAcces Width DecAcces Length DecAcces Product Type DecAcces Species Displays Description Displays Group ProductLine PropertyId ValueIdColPosts Diamenter 6ColPosts Diamenter 8 ColPosts Diamenter 10ColPosts Diamenter 12ColPosts Diamenter ----- ColPosts Length 3072ColPosts Length 3840ColPosts Length ----- When I take the above and relate it to an Item in the table below. I want to select a product line like ColPost and get the data below that.tblItemValueItemId ProductLinePropertyIdValueId I would want to see a result something like this for ColPosts with the ValueId's under their appropriate column.ItemId Diameter Length Type Special GroupAnd when I chose DecAces I would want this:ItemId Thickness Width Length ProductType Species |
 |
|
|
|
|
|