tags:

views:

25

answers:

2

As seen here: http://www.tsqltutorials.com/pivot.php

What if I don't have a column I can perform a SUM upon? How do I get a pivot'ed table result?

Thanks,

Matt.

A: 

There's always COUNT(0), another option is to create a common table expression and create an extra column on top of your query with the appropriate value and then use that for the PIVOT.

Don
Could DISTINCT be used?
Matt W
A: 

Could you not just add a column with an alias and then refer to the alias, style:

select bar, baz, 0 as foo from tabletable

Would that work?

MatthieuF
What would that look like? In my example I always end up with numbers where the values should be.
Matt W