导航
  • 主页
  • 基础类
  • 应用实例
  • 新技术前沿

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

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' 附近有语法错误。
...全文
294 点赞 收藏 5
写回复
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
回复
发动态
发帖子
MS-SQL Server
创建于2007-09-28

3.2w+

社区成员

MS-SQL Server相关内容讨论专区
申请成为版主
社区公告
暂无公告