我们可以看到,总共有25条要求,老规矩,一个一个来,以实验一的数据为基础
select *
from student;
select ssex,sage,sdept
from student
where not sdept='is' and not sdept='cs';
select sno,Grade
from sc
where cno=004
order by Grade asc;
select cno,count(*)
as '选课人数'
from sc
group by cno;
select sno,sname,sdept,sage
from student
where sage>18 and sage<20
select *
from student
where sname like('刘_晨')
select sno
from sc
where cno='001' and sno in (select sno from sc where cno='002')
select sname,(2018-sage) as '出生年份'
from student
where (2018-sage)>0
select sno,cno
from sc where grade IS NULL
select sno,sname
from student
where sno in ( select sno from sc where grade<60 group by sno having count(*)>=3 )
select avg(grade)
from sc
where cno='001'
select course1.cno,course2.cpno
from course course1,course course2
where course1.cpno=course2.cno
select student.* ,sc.*
from student
right join sc on student.sno=sc.sno
select sname,sdept
from student
where sno in(select sno from sc group by sno having min(grade)<60)
select sname
from student
where sno in(select sno from sc group by sno having min(grade)>90)
select *
from student
where sage=(select sage from student where sname='刘晨')
select sname,sage
from student
where sno in(select sno from sc where cno in(select cno from course where cname='数据库'))
select *
from student
where sage<any(select sage from student where sdept='is') and sdept<>'is'
SELECT sname
from student
where sno in(select sno from sc group by sno having count(cno)=7)
select *
from sc where cno='001'and sno not in(select sno from sc where cno='002')
select avg(sage)
from student
where sno in(select sno from sc where cno='003')
select distinct cno ,count(sno)
from sc
group by cno
having count(sno)>3
order by 2 desc,cno asc
select sname ,sage
from student where sage>(select avg(sage) from student where ssex='女')and ssex='男'
select *
from course where cno in (select cno from sc where sno='95001')
and cno in (select cno from sc where sno='95002')