一个小问题 问题:查询选修了4门以上的课程的学生学号及姓名.有两个表:student和grade;分别为:请问查询语句?最好能讲详细点.谢谢. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 抱歉,那个图片太小;问题:查询选修了4门以上的课程的学生学号及姓名.有两个表:student和grade分别为: select a.sno,a.namefrom student a,grade bwhere a.sno=b.snoand b.cno in(select cno from grade group by cno having count(1)>=4) 我解释一下吧,grade表中的cno是选修的课程号 小F,不用B表吧,FROM 后面 select a.sno,a.namefrom student a,grade bwhere a.sno=b.snoand (select count(1) from grade where cno sno=a.sno)>=4 select a.sno,a.namefrom student a,grade bwhere a.sno=b.snoand (select count(1) from grade where cno sno=b.sno)>=4 student和gradeselect a.sno,a.namefrom student awhere a.sno in(select sno from grade group by sno having count(1)>=4) select a.sno,a.namefrom student awhere a.sno in(select sno from grade group by sno having count(1)>=4) --难道是这样?select a.sno,a.namefrom student a,grade bwhere a.sno=b.snoand b.sno in(select sno from grade group by sno having count(1)>=4) 10楼正解,但是为什么是count(1),1是什么意思啊?为什么放在count中啊? 多价格级别分组,多单位不同价格数据设计问题 本地ACESS实时同步到服务器SQL SERVER2000中 关于索引问题(在线等) SQL查询,分组流水号问题 为 200分求创建临时表(sqlserver)加分 扩展存储过程中,如何调用系统中的其它存储过程? SQLSERVER触发器UPDATE问题_多条记录但是只执行了一次 能够用系统管理员权限访问某数据库服务器,问: 请问高手!在sql企业管理器怎么将数据很长的数据添加到text类型的字段中!谢谢 sql多表查询的问题,帮帮忙吗?没分了!我急!!! 简单的数据表设计问题 sql server 2005 如何判断xml字段 为空 ?
问题:
查询选修了4门以上的课程的学生学号及姓名.
有两个表:student和grade
分别为:
a.sno,a.name
from
student a,grade b
where
a.sno=b.sno
and
b.cno in(select cno from grade group by cno having count(1)>=4)
a.sno,a.name
from
student a,grade b
where
a.sno=b.sno
and
(select count(1) from grade where cno sno=a.sno)>=4
a.sno,a.name
from
student a,grade b
where
a.sno=b.sno
and
(select count(1) from grade where cno sno=b.sno)>=4
select
a.sno,a.name
from
student a
where
a.sno in(select sno from grade group by sno having count(1)>=4)
a.sno,a.name
from
student a
where
a.sno in(select sno from grade group by sno having count(1)>=4)
select
a.sno,a.name
from
student a,grade b
where
a.sno=b.sno
and
b.sno in(select sno from grade group by sno having count(1)>=4)