select sage from student where sage = (select sage from student where sname=“刘晨”) and sname <>’刘晨’;
select sname,cno,grade from student join sc on student.sno=sc.sno;
select count(cno) from sc join student on student.sno=sc.sno where sname=“刘晨”; select count(cno) from sc where sno=(select sno from student where sname=“刘晨”);
Select(distinct(去掉重复)) sname,cno from student join sc on student.sno=sc.sno where cno=“c01” or cno=“c02”; select sname from student where sno in(select sno from sc where cno = ‘c01’ or cno = ‘c02’);
select count(cno) from sc join student on student.sno=sc.sno where sname=“李勇”;
select avg(grade) from sc join student on sc.sno=student.sno where sname=“王名”; select avg(grade) from sc where sno =(select sno from student where sname=‘王名’);
) select student.sno,sname,cname,grade from student join sc on student.sno=sc.sno join course on course.cno=sc.cno;
select sname,sc.sno from student join sc on student.sno=sc.sno where cno=“c03” and grade>85 group by sname; select sno,sname from student where sno in (select sno from sc where cno = ‘c03’ and grade >85);
select max(grade) from sc join course on course.cno=sc.cno where cname=‘数据库’; select max(grade) from sc where cno =(select cno from course where cname=‘数据库’);
select cname,grade from course join sc on course.cno=sc.cno join student on student.sno=sc.sno where sname=“刘晨”;
select sum(ccredit) from course join sc on sc.cno=course.cno join student on sc.sno=student.sno;
select sname from student join sc on student.sno=sc.sno join course on course.cno=sc.cno where cname=“数据库”; select sname from student where sno in(select sno from sc where cno =(select cno from course where cname=‘数据库’));
update student set dno = (select dno from student where sname=“刘晨”) where sname=“王名”;
delete from student where sno in(select sno from sc where cno=“c04”);
delete from course where cno not in (select cno from sc);