MS SQL server Pivot Tables

Baz

Baz

Soldato
Joined
9 Dec 2002
Posts
4,376
Location
Peterborough
Trying to pivot a lot of data in SQL server, and have been playing about with Pivot tables.... Problem is, the data I want to pivot is not always numbers, its often text.

The statement I am using is...

Code:
Select [i]Column1[/i],
	 SUM(CASE [i]Column2 [/i]WHEN '[i]text1[/i]' THEN [i]Column3 [/i]ELSE 0 END) AS '[i]text1[/i]',
	 SUm(CASE [i]Column2 [/i]WHEN '[i]text2[/i]' THEN [i]Column3 [/i]ELSE 0 END) AS '[i]text2[/i]'
FROM [i]Table [/i]where [i]ID[/i] = ID
Group By [i]Column1[/i]

But it falls over if I have text in there..

Is there a way of doing a pivot in SQL with Text...
 
Back
Top Bottom