In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
PIVOT function, row to column
The PIVOT function has the following format:
PIVOT(([Aggregate Column Value]) FOR [Column Name Before Row Conversion] IN([Column Name After Row Conversion 1],[Column Name After Row Conversion 2],[Column Name After Row Conversion 3],... [column name after row transition N]))
That is, we use SUM,COUNT,AVG and other Sql aggregation functions, that is, the aggregation method of calculating columns after row conversion.
[Aggregate column values] Column names to aggregate
[Column name before row to column] This is the column name that needs to be converted from row to column.
[Column name after row conversion] Here, you need to declare that the value of the row will be converted to the column name after column conversion, because the column name after conversion is actually the value before conversion, so in the above format,[Column name after row conversion 1],[Column name after row conversion 2],[Column name after row conversion 3],...... [The column name N after row conversion] is actually the value of each row before row conversion.
SELECT FROM [StudentScores] /Data Sources/
AS P
PIVOT
(
SUM(Score/Score----Value of column after row transfer/) FOR
p.Subject/Course----Column/ IN (Value of [Language],[Math],[English],[Biology]/Column */)
) AS T
SqlServer PIVOT function quickly realize row to column, UNPIVOT realize column to column- PowerCoder -Blog Garden http://www.cnblogs.com/OpenCoder/p/6668882.html
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un