September 3, 2007 at 7:44 am
Hi
Following is the scenario I am facing:
Table#A
AttributeID | AttributeName
1 Alpha
2 Brave
3 Charlie
Table#B
ColumnID | ColumnValue
1 Reading1
2 Reading2
3 Reading3
and Finally Mapper Table
MappingID | ColumnID | AttributeID
1 1 1
2 1 2
3 1 3
What I want is a structure like this :
-------------------------------------------------------------------------------
| Reading1 | Reading 2 | Reading 3
-------------------------------------------------------------------------------
Alpha | x | |
-------------------------------------------------------------------------------
Bravo | y | |
-------------------------------------------------------------------------------
Charlie | z | |
--------------------------------------------------------------------------------
This is basically a report format and i cant develop a cross tab cuz it has some grouping and calculation issue so is there a possible way out in T-Sql. I am using sql server 2005 and pivot command is not helping me beacause i dont know the number of columns to pivot data, please help me out here ppl.
September 3, 2007 at 8:08 am
You would need to build up the pivot statement and then execute this. An example is on:
http://www.sqlservercentral.com/forums/shwmessage.aspx?forumid=338&messageid=367396#bm367610
Regards,
Andras
September 3, 2007 at 5:13 pm
You'd probably get more help if your output example matched the example inputs in your post... for example... where the heck did the "x", "y", and "z" come from???
--Jeff Moden
Change is inevitable... Change for the better is not.
September 4, 2007 at 6:50 am
where the heck did the "x", "y", and "z" come from |
Probably from the aforementioned 'some grouping and calculation issue' in the original post.
Far away is close at hand in the images of elsewhere.
Anon.
September 4, 2007 at 7:23 am
well we will put values against these values, see above 2 tables are just the tables of where rows and cols are defined there is another table where we define values against each of them like:
ID | RowID | ColID | Value
1 ... ... Some Value
2 ... ... Some Value
September 4, 2007 at 7:28 am
You're missing the point, Uzwa... From the data examples you have in the first post, what do you want the output to look like?
--Jeff Moden
Change is inevitable... Change for the better is not.
September 6, 2007 at 12:34 am
I want a cross tab basically, i can do it by Crystal Cross tab reports but problem is I have to perform not only addition but subtraction and discounts on data so i want sql to generate data for my in an order so that i can fit it in a tabular fashion and perform calculations.
September 6, 2007 at 6:49 am
You're still missing the point... you provided certain base data in your original post and an output sample that cannot be...
I'm just asking for you to provide the correct output sample so we can help you with the code... not going to waste time guessing what you want...
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply