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
 SQL Server Development (2000)
 Rotate table by 90 degrees!

Author  Topic 

t1g312
Posting Yak Master

148 Posts

Posted - 2003-12-24 : 07:43:08
Hi all,

I have a table that has 3 fields: id, Field and value. I need to create a view which has some of these "Fields" as column names and value as column values. How do I do that?

TIA

Adi

-------------------------
/me sux @sql server

mohdowais
Sheikh of Yak Knowledge

1456 Posts

Posted - 2003-12-24 : 08:02:42
Search this site and forums for "crosstab" or "pivot" queries. Basically you'll get something to the order of :

SELECT
SUM(CASE Field WHEN x THEN value else 0 END) AS x,
SUM(CASE Field WHEN y THEN value else 0 END) AS y,
...


Owais

We make a living out of what we get, but we make a life out of what we give.
Go to Top of Page
   

- Advertisement -