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 2000 Forums
 Transact-SQL (2000)
 row to column

Author  Topic 

jung1975
Aged Yak Warrior

503 Posts

Posted - 2005-08-28 : 20:10:04
how can I convert row to column?

I have a table looks like:

Risk count
----- ---
High 90
Moderate 76
Low 129

,but would like to display


High Moderate Low
90 76 126





madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-08-29 : 00:48:06
How many rows do you have?

If its only 3, then try this


Select distinct
High=(Select count from @t where risk='High'),
Moderate=(Select count from @t where risk='Moderate'),
Low=(Select count from @t where risk='Low')
from yourTable

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -