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
 General SQL Server Forums
 New to SQL Server Programming
 Pivot Table - not sure?

Author  Topic 

Grifter
Constraint Violating Yak Guru

274 Posts

Posted - 2011-03-02 : 06:10:25
Hi

I have a simple result set that I would like to put into a column display and have been reading about pivot table but not sure if this is what I need. I have the following:


columnA ColumnB
======= =======
A Yes
B Yes
C No
D Yes


and want it to display like this:


A B C D
=== === === ===
Yes Yes No Yes


Anything that anyone can suggest?

Thanks

Grifter

Grifter
Constraint Violating Yak Guru

274 Posts

Posted - 2011-03-02 : 06:57:19
I have used this, whcih returns what I want but am now wondering whether I can include this in my query. the problem is I need to include the fields in a report and so need each field like A, B, C, D to pull into a grid display in a report

select  MAX(Case WHEN columnA = 'Yes'
THEN ColumnB END) AS 'A'
Go to Top of Page
   

- Advertisement -