How to produce cross-expression data table (pivot table) Part 2 (PIVOT, UNPIVOT) in SQL

How to produce cross-expression data table (pivot table) Part 2 (PIVOT, UNPIVOT) in SQL


Before use SQL2000 meow when the table data to produce cross (Excel pivot table referred to), with the following meow way to deal with this

http://www.dotblogs.com.tw/topcat/archive/2008/04/14/2909.aspx

This can be used in the same way inside SQL 2005, but 2005 has added a more convenient and something that can be handled more concise. This thing is [PIVOT], the magic is, in addition to produce cross through PIVOT data tables, table data can also cross through UNPIVOT back to the original way (which for some helpful normalized data tables yo).

^_^

Related note Online Book SQL2005 has said very clearly, small meow direct link to the TechNet article, please refer to

http://technet.microsoft.com/zh-tw/library/ms177410.aspx


The following is the signature:

  • Welcome to the site posted the article, but the gist of your posts on the plus - posted, and attach Benpian hyperlinks station name in the article [topcat extreme cohesion between the Shan dance], thanks you for your cooperation.
  • Most small meow meow small article will be familiar language to write VB.NET, C # if you need the Code, perhaps you can try online conversion tool, providing several reference here
    • http://converter.telerik.com/
    • http://www.carlosag.net/tools/codetranslator/
    • http://www.developerfusion.com/tools/convert/vb-to-csharp/

Microsoft MVP
Visual Studio and Development Technologies
(2005~Now)

topcat
Blog:http://www.dotblogs.com.tw/topcat


Original: Large column  how to generate cross-expression data table (pivot table) Part 2 (PIVOT, UNPIVOT) in SQL


Guess you like

Origin www.cnblogs.com/petewell/p/11518130.html