|
楼主 |
发表于 2010-4-1 14:26
|
显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
我已经计算出来2楼的结果,语句繁琐的我要吐了。
select 班级,科目,count(成绩) as 80分以下,0 as 90分以下,0 as 100分以下,0 as 110分以下,0 as 110分以上 from(
select 班级,"语文" as 科目,语文 as 成绩 from [sheet2$] union all
select 班级,"数学" as 科目,数学 as 成绩 from [sheet2$] union all
select 班级,"英语" as 科目,英语 as 成绩 from [sheet2$] union all
select 班级,"物理" as 科目,物理 as 成绩 from [sheet2$] union all
select 班级,"化学" as 科目,化学 as 成绩 from [sheet2$] union all
select 班级,"历史" as 科目,历史 as 成绩 from [sheet2$] union all
select 班级,"政治" as 科目,政治 as 成绩 from [sheet2$]) where 成绩<80 group by 班级,科目 union all
select 班级,科目,0,count(成绩) as 90分以下,0,0,0 from(
select 班级,"语文" as 科目,语文 as 成绩 from [sheet2$] union all
select 班级,"数学" as 科目,数学 as 成绩 from [sheet2$] union all
select 班级,"英语" as 科目,英语 as 成绩 from [sheet2$] union all
select 班级,"物理" as 科目,物理 as 成绩 from [sheet2$] union all
select 班级,"化学" as 科目,化学 as 成绩 from [sheet2$] union all
select 班级,"历史" as 科目,历史 as 成绩 from [sheet2$] union all
select 班级,"政治" as 科目,政治 as 成绩 from [sheet2$]) where (成绩<90 and 成绩>=80)group by 班级,科目 union all
select 班级,科目,0,0,count(成绩) as 100分以下,0,0 from(
select 班级,"语文" as 科目,语文 as 成绩 from [sheet2$] union all
select 班级,"数学" as 科目,数学 as 成绩 from [sheet2$] union all
select 班级,"英语" as 科目,英语 as 成绩 from [sheet2$] union all
select 班级,"物理" as 科目,物理 as 成绩 from [sheet2$] union all
select 班级,"化学" as 科目,化学 as 成绩 from [sheet2$] union all
select 班级,"历史" as 科目,历史 as 成绩 from [sheet2$] union all
select 班级,"政治" as 科目,政治 as 成绩 from [sheet2$]) where (成绩<100 and 成绩>=90)group by 班级,科目 union all
select 班级,科目,0,0,0,count(成绩) as 110分以下,0 from(
select 班级,"语文" as 科目,语文 as 成绩 from [sheet2$] union all
select 班级,"数学" as 科目,数学 as 成绩 from [sheet2$] union all
select 班级,"英语" as 科目,英语 as 成绩 from [sheet2$] union all
select 班级,"物理" as 科目,物理 as 成绩 from [sheet2$] union all
select 班级,"化学" as 科目,化学 as 成绩 from [sheet2$] union all
select 班级,"历史" as 科目,历史 as 成绩 from [sheet2$] union all
select 班级,"政治" as 科目,政治 as 成绩 from [sheet2$]) where (成绩<110 and 成绩>=100)group by 班级,科目 union all
select 班级,科目,0,0,0,0,count(成绩) as 110分以上 from(
select 班级,"语文" as 科目,语文 as 成绩 from [sheet2$] union all
select 班级,"数学" as 科目,数学 as 成绩 from [sheet2$] union all
select 班级,"英语" as 科目,英语 as 成绩 from [sheet2$] union all
select 班级,"物理" as 科目,物理 as 成绩 from [sheet2$] union all
select 班级,"化学" as 科目,化学 as 成绩 from [sheet2$] union all
select 班级,"历史" as 科目,历史 as 成绩 from [sheet2$] union all
select 班级,"政治" as 科目,政治 as 成绩 from [sheet2$]) where 成绩>=110 group by 班级,科目
[ 本帖最后由 抹香鲸2009 于 2010-4-1 16:31 编辑 ] |
|