查询有二门以上(含两门)不及格课程的学生姓名及其总成绩。

wxxloveu 2007-12-14 12:40:59
查询有二门以上(含两门)不及格课程的学生姓名及其总成绩。
select sname,sum(grade) sumgrade
from student,sc
group by sname
where count(sno)>student.sno in (select sno from sc where grade<60)
服务器: 消息 156,级别 15,状态 1,行 4
在关键字 'where' 附近有语法错误。
...全文
865 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
wxxloveu 2007-12-14
  • 打赏
  • 举报
回复
sorry,It should be
select sname,sum(grade) sumgrade
from student,sc
group by sname
where student.sno in (select sno from sc where grade<60)
xiaoronghu 2007-12-14
  • 打赏
  • 举报
回复
[
select sname,sum(grade) sumgrade
from student,sc
where student.sno=sc.sno and student.sno in (select sno
from sc
where grade<60
group by sno
having count(*)>1)
group by sname
wxxloveu 2007-12-14
  • 打赏
  • 举报
回复
select sname,sum(grade) sumgrade
from student,sc
where student.sno in (select sno
from sc
where grade<60
group by sno
having count(*)>1)
group by sname
gonggou123 2007-12-14
  • 打赏
  • 举报
回复
select student.sno,student.sname,sum(grade) ,sum(case when grade <60 then 1 else 0 end) from student ,sc where student.sno=sc.sno group by student.sno,student.sname
having sum(case when grade <60 then 1 else 0 )> 1
gonggou123 2007-12-14
  • 打赏
  • 举报
回复
select sno,sname,sum(grade) ,sum(case when grade <60 then 1 else 0 ) from student ,sc where student.sno=sc.sno group by sno,sname
having sum(case when grade <60 then 1 else 0 )>1

34,837

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧