Home  >  Article  >  Database  >  几条sql语句

几条sql语句

WBOY
WBOYOriginal
2016-06-07 17:38:37945browse

1、行、列转换 成绩(姓名 varchar ( 10 ),科目 varchar ( 10 ),分数 int ) ,, 74 ) ,, 83 ) ,, 93 ) ,, 77 ) ,, 84 ) ,, 94 ) ,, 81 ) ,, 86 ) ,, 91 ) 姓名, 分数 ) as 语文, 分数 ) as 数学, 分数 ) as 物理 from 成绩 group by 姓名 成绩 pivot( max (分

1、行、列转换

成绩(姓名 varchar(10),科目 varchar(10),分数 int) ,,74) ,,83) ,,93) ,,77) ,,84) ,,94) ,,81) ,,86) ,,91) 姓名, 分数 ) as 语文, 分数 ) as 数学, 分数 ) as 物理 from 成绩 group by 姓名 成绩 pivot(max(分数) for 科目 in (语文,数学,物理)) a 成绩(姓名 varchar(10),语文 int,数学 int,物理 int) ,74,83,93) ,77,84,94) ,81,86,91) 姓名,科目,语文 as 分数 from 成绩 科目,数学 as 分数 from 成绩 科目,物理 as 分数 from 成绩 姓名,科目,分数 from 成绩 unpivot(分数 for 科目 in(语文,数学,物理)) t ,

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