sql server 2012 行转列
table_sourcePIVOT(
聚合函数(value_column)
FOR pivot_column
IN(<column_list>)
)
对于一个字段的汇总和转置,只用一次。
) tb pivot(max(copies) for ORDER_TYPE in (,,,)) tb
对于多个字段的汇总和转置,要嵌套多次。
) tb pivot(max(copies) for ORDER_TYPE in (,,,)) tb
) tb1 pivot(max(price) for order_type1 in (,,,)) tb1
) tb2 pivot(max(amt) for order_type2 in (,,,)) tb2
页:
[1]