Table_source
PIVOT (
Aggregation Functions ( Value_column )
For Pivot_column
In (<column_list>)
)
The rollup and transpose of a field is used only once.
) TB Pivot (max (copies) for Order_type in ([11],[12],[13],[14])) TB
650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M00/86/C0/wKiom1fJL62BzNw0AAAx3ojxOmk986.png-wh_500x0-wm_3 -wmp_4-s_3900535619.png "title=" qq picture 20160902155111.png "alt=" Wkiom1fjl62bznw0aaax3ojxomk986.png-wh_50 "/>
For totals and transpose of multiple fields, it is nested multiple times.
) TB Pivot (max (copies) for Order_type in ([11],[12],[13],[14])) TB
) TB1 pivot (max (price), order_type1 in ([11],[12],[13],[14])) tb1
) TB2 Pivot (Max (AMT) for Order_type2 in ([11],[12],[13],[14]) TB2
650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M02/86/BF/wKioL1fJL_Czh9HvAABlXUC3gEY984.png-wh_500x0-wm_3 -wmp_4-s_2273479700.png "title=" qq picture 20160902155003.png "alt=" Wkiol1fjl_czh9hvaablxuc3gey984.png-wh_50 "/>
SQL Server 2012 row to column