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 |
|
zubairmasoodi
Starting Member
35 Posts |
Posted - 2007-05-08 : 05:07:29
|
| Hii have a sql Statment which has the following Result set Stats Statname---- ------ 54 Members585 PRESENTATION1083 VIEWS1138 VIEWlOGS i Want this in a single Row as follows Members PRESENTATION VIEWS VIEWlOGS------- ----------- ---- ---------54 585 1083 1183How can i design a query for this Please help |
|
|
pbguy
Constraint Violating Yak Guru
319 Posts |
Posted - 2007-05-08 : 05:14:45
|
| declare @tt table (Stats int, Statname varchar(30))insert @ttselect 54, 'Members' unionselect 585, 'PRESENTATION' unionselect 1083, 'VIEWS' unionselect 1138, 'VIEWlOGS' Select Max(Case when Statname = 'Members' then Stats end) as Members,max(Case when Statname = 'PRESENTATION' then Stats end) as PRESENTATION,Max(Case when Statname = 'VIEWS' then Stats end) as VIEWS,Max(Case when Statname = 'VIEWlOGS' then Stats end) as VIEWlOGS from @tt |
 |
|
|
zubairmasoodi
Starting Member
35 Posts |
Posted - 2007-05-08 : 05:28:07
|
| Thanks dear, it worked |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-05-08 : 10:28:29
|
| Also read about Cross-tab reports in sql server help fileMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|