Advertisement

12.20.2006 at 08:20AM PST, ID: 22099316
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.4

Need Select statement to convert detail view to table view

Asked by creepy42 in MS SQL Server

Tags: , , , ,

I have a table structure consisting of 3 tables.
Table 1. MasterTable consists of 2 columns, ObjectID, ObjectName
Table 2. DetailTable consists of 3 columns, ObjectID, PropertyName, Value
Table 3. PropertyTable consists of 1 column PropertyNames

So if the objects in question is for examle a ball with properties Size and Color, info is stored about them as
Table 1
ObjectID            ObjectName
1                       BigRed
2                       SmallBlue
----------------------------------
Table 2
ObjectID                     PropertyName         Value
1                                Size                       Big
1                                Color                      Red
2                                Size                        Small
2                                Color                       Blue
-------------------------------------
Table 3
PropertyNames
Size
Color
-------------------------------------


And i need to create a view from this that would look like
NeededView
ObjectID                     ObjectName               Size                Color
1                                BigRed                       Big                 Red
2                                SmallBlue                   Small             Blue

------------------------------------------------------------------------------

Properties will likely be added and removed quite often, and every time i will need to recreate the view to display the current set of properties.

So far the only version i have been able to come up with has every property treated like this:
SELECT     m.ObjectID, m.ObjectName,
(SELECT d.Value WHERE d.ObjectID = m.ObjectID AND d.PropertyName = "Size") as Size,
(SELECT d.Value WHERE d.ObjectID = m.ObjectID AND d.PropertyName = "Color") as Color
FROM         MasterTable m INNER JOIN
                      DetailTable d ON m.PBXID = d.PBXID

however in practise the object is going to have around 50 properties, so i would be doing 50 select statements to compile every row of this view.
Is there a more gracious way to accomplish this?Start Free Trial
[+][-]12.20.2006 at 08:23AM PST, ID: 18174232

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]12.20.2006 at 08:24AM PST, ID: 18174235

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: MS SQL Server
Tags: table, convert, view, select, statement
Sign Up Now!
Solution Provided By: matthewspatrick
Participating Experts: 2
Solution Grade: A
 
 
[+][-]12.20.2006 at 09:23AM PST, ID: 18174683

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.20.2006 at 10:09AM PST, ID: 18175022

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12.20.2006 at 10:11AM PST, ID: 18175032

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12.20.2006 at 10:52AM PST, ID: 18175342

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32