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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Sql

Author  Topic 

bondwiththebest
Starting Member

46 Posts

Posted - 2009-04-27 : 22:30:02
Hi everyone !

I have a table defined like this below....

ID CID TOTAL M_1....M_7 B1.....B7 H1....H7
1 abb 5 11 12 13 null 23 55 66 null 23 45 54 null
2 bgb 1 .....

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

Here my output depeneds on the "total" Column. I need something like

ID CID TOTAL M B H
1 abb 1 11 23 23
2 abb 2 12 55 45
3 abb 3 13 66 54
4 bgb 1 .............


The no of row in the new table depends upon the "total " columns.. I am not really sure how to use pivout and then get the query...can anyone help me????


khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-04-27 : 22:38:10
quote:
The no of row in the new table depends upon the "total" columns

New Table : You want to create a new table out of this existing table ? Or just an output of the query ?
no of row : What do you mean ? How ?
Or is it the new column M is a summation of the value of column M_1, M_2 etc ?


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

bondwiththebest
Starting Member

46 Posts

Posted - 2009-04-28 : 08:20:48
The result came out crappy when i posted...

I just want the output of query to be like that..... And M ,B, H are NOT the summation of M_1,M_2...,B_1,B_2....etc
Go to Top of Page

sakets_2000
Master Smack Fu Yak Hacker

1472 Posts

Posted - 2009-04-28 : 08:25:21
explain more, format your post.. Its not clear.
Go to Top of Page
   

- Advertisement -