oracle数据库查询

来源:百度知道 编辑:UC知道 时间:2024/06/23 03:55:34
1,如果一张学生表中有两个学生的名字相同,怎么查出相同学生的信息
2,每个班级的CNO等于1的考试平均分,并按从高到低排序(如图)
知道的说下,谢谢

1.select * from s
where sname in (select sname from s
group by sname having count(sname)>=2)

2.select sclass,avg(score)
from c,s
where c.sno=s.sno and cno=1
group by sclass
order by 1 desc

1.名字相同,但学号肯定是不能相同的,设学号为主键。用学号查就是唯一的了。或者在加上别的条件查询。
2.
select avg(score)
from 表1,表2
where 表2.sno=表1.sno and cno=1
group by sclsss
order by avg(score) desc;