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 |
|
Lewis
Starting Member
6 Posts |
Posted - 2010-03-23 : 13:38:40
|
| Hi, I have a table with several integer columns with values ranging from 1 to 5. I need to create a report from this table. What I want to archive is to create one row for each column like the following format1 2 3 4 510% 5% 70% 10% 5%Can I do this by a simple query or I have to write a store procedure?thanks |
|
|
vijayisonly
Master Smack Fu Yak Hacker
1836 Posts |
Posted - 2010-03-23 : 13:40:39
|
| What do those percentages mean? How are you deriving that?And....1,2,3,4 and 5 are the values in 5 different columns? |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-03-23 : 13:42:48
|
| you can . use PIVOT statement------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
Lewis
Starting Member
6 Posts |
Posted - 2010-03-23 : 13:47:38
|
They are just percentage of the total numbers.quote: Originally posted by vijayisonly What do those percentages mean? How are you deriving that?And....1,2,3,4 and 5 are the values in 5 different columns?
|
 |
|
|
Lewis
Starting Member
6 Posts |
Posted - 2010-03-23 : 13:53:51
|
Thanks, this is what I am looking for.quote: Originally posted by visakh16 you can . use PIVOT statement------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
|
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-03-23 : 13:55:10
|
| what? 1,2,3 etc are also %s? can you show how data resides in your table then?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
Lewis
Starting Member
6 Posts |
Posted - 2010-03-23 : 14:17:07
|
I got it under control. Pivot is a great function.quote: Originally posted by visakh16 what? 1,2,3 etc are also %s? can you show how data resides in your table then?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
|
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-03-23 : 14:23:36
|
| cool------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|
|
|