單表問題

--查詢平均成績大於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

相關文章
相關標籤/搜索