SQL Server 2012 row to column

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.