单表问题

--查询平均成绩大于60分的同窗的学号和平均成绩ci

select sid as '学号' , avg(score) as '平均成绩'
 from SC
  group by sid
   having AVG(score)>60 select

--查询姓“李”的老师的个数
select COUNT(Tname) as '姓李个数'
  from Teacher
    where Tname like '李%'统计

--3: 查询每门课程被选修的学生数查询

select COUNT(sid) as '选秀的学生数',cid as '被选修的课'
  from SC
   group by cidvi

--4: 查询男生、女生人数
select count(Sid) as '人数',Ssex as '性别' from Student group by Ssexco

--5: 查询姓“张”的学生名单
select Sname from Student where Sname like '张%'let

--6:查询同名同性学生名单,并统计同名人数
select COUNT(Sname) as '同名人数',Sname as '姓名'
  from Student as s
   group by Sname
    having COUNT(Sname)>1delete

--7: 检索至少选修两门课程的学生学号
select sid as '学号'
 from SC
  group by sid
   having COUNT(sid)>=2 

--8: 删除“002”同窗的“001”课程的成绩

delete from SC where sid = 2 and cid = 1

相关文章
相关标签/搜索