选课表tSC,学生表tStu,课程表tCou
1.求选课人数<10的课程(group,hanving 的用法)
select tSC.cname ,count(sno) from tSC Group by tSC.cno having count(*)>3
2.学生成绩表(连接)
select tStu.sname,tSC.cname,tSC.score from tStu,tSC where tStu.sid=tSC.sid
3.每门课的先行课(自连接)
select First.cno,Second.cpno from tCou First,tCou Second Where First.cpno=Second.cno
4.找和刘晨一个系的的学生(=)
select tStu.sname from tStu where tStu.sdept=(select sdept from tStu where sname='刘晨')
5.查找比信息系所有年龄都小的学生姓名(<,<>)
select sname from tStu where sage<(select MIN(sage) from tStu where sdept='IS') and sdept<>'IS'
6.查询选修过1号课程的学生名字(exists)
select sname from tStu WHERE EXISTS (select * from tSC where sid=tStu.sid AND cid='1')