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 |
de4ever@gmail.com
Starting Member
36 Posts |
Posted - 2012-01-27 : 13:00:58
|
Hi All,I have some tables like ContentTable: -------------- ContentId Name BookId1 Content1 12 Content2 1 Variable Table:-------------------VariableId Name 1 Var12 Var23 Var3 4 Var4 Book Consists of multiple contents and variablevalue may be there for both book and contents or either of them.I have book level variable(with contentId null) and content level variable for a particular Book say Book1 as belowvariablevalue Table ID VariableId ContentId BookIId Value 1 1 1 1 Content1Var1Value 2 2 1 1 Content1Var2Value 3 1 NULL 1 Book1Var1Value 4 2 2 1 Content2Var2Value 5 3 NULL 1 Book1Var3ValueAs you can see I have var1 associated with both content and book and Var2 only associated with content and var3 only associated with Book.Now I need output data as Contents Var1 Var2 Var3-------- ---- ----- ----- Book1Var1Value {None} Book1Var3ValueContent1 Content1Var1Value Content1Var2Value {None}Content2 {None} Content2Var2Value {None}Basically if an associattion is ther for particular variable at Book Level,but missing in content level then we need to put {None} in those placeAgain if an associattion is there for particular variable at Content level ,but missing in book level then we need to put {None} in those place for book.First row with empty content signifies book level variable.Now I need help in pivoting data in above mentioned format .Please help me out .Thanks |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
|
|
|