select * from student
go
select * from student
where sdept='cs'
go
select sno,sname
from student
where sdept='cs' and sage not between 19 and 21
go
select max(sage)
from student
go
select sno,sname
from student
where sdept='cs' and sage=(select max(sage)
from student
where sdept='cs'
)
go
select sno,sname,sdept
from student s1
where sage=(select max(sage)
from student
where sdept=s1.sdept
)
go
select count(*)
from student
where sdept='cs'
go
select sdept,count(sno) as sm
from student
group by sdept
order by sm
go
<br><br>**********************************************<br><br>select sdept,count(*) as dd<br>from student<br>group by sdept<br>order by dd<br>go<br>
select sdept,count(sage) as sm
from student
group by sdept
order by sm desc
go
<br><br>select sdept,avg(sage)dd<br>from student<br>group by sdept<br>order by dd desc<br>go<br><br>
select cno,cname from course
go
<br><br>select cname from course<br>go<br><br><br>
select cname,ccredit
from course
where cpno is null
go
select sum(ccredit)
from course
where cpno is null
go
select sno,count(sc.cno),count(ccredit),avg(grade)
from sc,course
where sc.cno=course.cno
group by sno
go
select cno,count(sno),avg(grade)
from sc
group by cno
go
select sdept,sc.sno,avg(grade)
from sc,student
where sc.sno=student.sno
group by sc.sno,sdept
having avg(grade)>85
order by avg(grade)<br>go
<br><br><br><br><br><br>
select distinct sc.sno,sname
from sc,student
where sc.sno=student.sno and (sc.cno='1' or sc.cno='2')
go
select distinct sc.sno,sname
from sc,student
where sc.sno=student.sno and sc.cno='1' and sc.sno in(select sno
from sc
where cno='2')
go
<br><br>**********************************<br>7、将“CS”系全体学生的成绩置零;<br><br>update sc set grade=0<br>where sno in <br> ( selsct sno <br> from student <br> where sdept='cs')<br>go<br><br><br>*****************************************<br><br><br><br>
select sc.sno,sname,grade
from sc,student,course
where sc.sno=student.sno and sc.cno=course.cno and course.cname='数据库系统' and grade<60
go
<br>
selsct sc.sno,sname,sc.cno,cname,grade<br>from student,sc,course<br>where student.sno=sc.sno and course.cno=sc.cno<br>go<br><br><br>
select sno,sname,sage
from student
where sno not in(select distinct sno from sc)
go
<br>select *<br>from student<br>where sno not in(select distinct sno from sc)<br>go<br><br>
select sno
from sc
group by sno
having count(cno)>=3
go
select distinct sno
from sc
where grade>80
go
select distinct sno
from sc
where sno not in(select distinct sno
from sc
where grade<80)
go
select sno
from sc
group by sno
having avg(grade)>80
go