sql语句问题。找出每个学生超过他选修课程平均成绩的课程号。
我这样写对吗selectsno,cnofromscgroupbysno,cnohavinggrade>=avg(grade)或者这样写selectSno,CnofromS...
我这样写对吗
select sno ,cno
from sc
group by sno,cno
having grade >= avg(grade)
或者这样写
select Sno,Cno
from SC
where Grade >=
(select avg (grade)
from sc
)
这都对吗? 展开
select sno ,cno
from sc
group by sno,cno
having grade >= avg(grade)
或者这样写
select Sno,Cno
from SC
where Grade >=
(select avg (grade)
from sc
)
这都对吗? 展开
6个回答
2017-06-03
展开全部
select sno,cno
from sc sc1
where grade>(
select avg(grade)
from sc sc2
where sc1.sno=sc2.sno)
from sc sc1
where grade>(
select avg(grade)
from sc sc2
where sc1.sno=sc2.sno)
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2015-10-14
展开全部
select sno,cno,grade from cs
where exists(select 1 from cs avgcs group by avgcs.cno having cs.cno=avgcs.cno and cs.grade>avg(avgcs.grade))
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
SELECT Sno,Cno FROM sc,(SELECT Sno,AVG(Grade) FROM sc
GROUP BY Sno) AS Avg_sc(avg_sno,avg_grade)
WHERE sc.Sno=Avg_sc.avg_sno AND sc.Grade>=Avg_sc.avg_grade;
GROUP BY Sno) AS Avg_sc(avg_sno,avg_grade)
WHERE sc.Sno=Avg_sc.avg_sno AND sc.Grade>=Avg_sc.avg_grade;
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询