如何用sql求重复平均值,表没有主键约束

如何申请cs的人gpa平均分比没申请cs的人的平均分高多少,用一个select语句完成(第一张表是apply,第二张是student)

img

img

不知道你的是不是oracle
select (select avg(gpa) from apply,student where apply.sid=student.sid and apply.major='cs' and apply.desicsion='Y')-(select avg(gpa) from apply,student where apply.sid=student.sid and apply.major='cs' and apply.desicsion='N' or apply.major<>'cs') from dual;