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 |
|
NasimCZD
Starting Member
1 Post |
Posted - 2009-02-24 : 13:45:13
|
| hi guys,I wrote a query that the results are in table A and I want to revese the results to table B....Would you please help me how I can write another query or complete my query?ThanksTable A: Name No. A 1 B 2 C 3 D 4 Table B: Name A B C D No. 1 2 3 4 |
|
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2009-02-24 : 13:46:34
|
| Read PIVOT. |
 |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-02-25 : 01:59:37
|
| go through this link toohttp://sqlblogcasts.com/blogs/madhivanan/archive/2007/08/27/dynamic-crosstab-with-multiple-pivot-columns.aspx |
 |
|
|
Nageswar9
Aged Yak Warrior
600 Posts |
Posted - 2009-02-25 : 02:10:59
|
| using Dynamic CrossTabselect sum(case when name = 'A' then no else 0 end) A,sum(case when name = 'B' then no else 0 end) B,sum(case when name = 'C' then no else 0 end) C,sum(case when name = 'D' then no else 0 end) DFROM @TEMP |
 |
|
|
Nageswar9
Aged Yak Warrior
600 Posts |
Posted - 2009-02-25 : 02:11:28
|
| Using PivotSELECT A,B,C,Dfrom @temppivot (SUM(no) for NAME in (A,B,C,D)) p |
 |
|
|
|
|
|