Home >Database >Mysql Tutorial > 03. 行列转换写法小结

03. 行列转换写法小结

WBOY
WBOYOriginal
2016-06-07 17:42:311199browse

行列转换,通常有2种方法,一是CASE WHEN/UNION;一是PIVOT/UNPIVOT。对于行值或列数不固定的情况,需要用动态SQL。 一. 行转列 RowToCol(ID int ,Code varchar ( 10 ),Value int ) Go insert RowToCol ,,,,,,,,,,,,,RowToCol

行列转换,通常有2种方法,香港空间,美国空间,美国服务器,一是CASE WHEN/UNION;一是PIVOT/UNPIVOT。对于行值或列数不固定的情况,需要用动态SQL。


一. 行转列

RowToCol ( ID int, Code varchar(10), Value int ) Go insert RowToCol ,,,,,,,,,,,,,RowToCol

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn