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?
总会有COUNT(0)
,另一个选择是创建一个公共表表达式,并在查询顶部创建一个具有适当值的额外列,然后将其用于PIVOT。
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?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.