select name '姓名',SUM(distinct score) '总分' from Table_1 group by name having SUM(distinct score)>100
select
(case when 语文>=80 then '优秀'
when 语文>=60 then '及格'
else '不及格') as 语文,
(case when 数学>=80 then '优秀'
when 数学>=60 then '及格'
else '不及格') as 数学,
(case when 英语>=80 then '优秀'
when 英语>=60 then '及格'
else '不及格') as 英语,
from table
select * from (select * from table group by name,grade) a group by name having sum(score)>100;
select
(case when 语文>=80 then '优秀'
when 语文>=60 then '及格'
else '不及格') as 语文,
(case when 数学>=80 then '优秀'
when 数学>=60 then '及格'
else '不及格') as 数学,
(case when 英语>=80 then '优秀'
when 英语>=60 then '及格'
else '不及格') as 英语,
from table
select name '姓名',SUM(distinct score) '总分' from Table_1 group by name having SUM(distinct score)>100我怎么感觉这个是不可以的,他还是没有起到去重的效果,如果同个人,不同课程,同样分数,这个语句结果就不对了
可以了 感谢大家。
第一题
select * from (select * from table group by name,grade) a group by name having sum(score)>100;
或者
select name '姓名',SUM(distinct score) '总分' from Table_1 group by name having SUM(distinct score)>100
都可以。谢谢两位!
第二题
select
(case when chinese >=80 then '优秀' when chinese>=60 then '及格' else '不及格' end) 语文,
(case when math >=80 then '优秀' when math >=60 then '及格' else '不及格' end) 数学,
(case when english >= 80 then '优秀' when english >=60 then '及格' else '不及格' end) 英语
from table;
原来是少了一个end。已经可以显示结果了,不过还有一个小问题不能按题目上的要求显示,去除那些空值。