0

在 jennifer widom 的 dbclass 中,她举了一个例子,让一所大学与他们申请者的最高 gpa 配对.. sql 如下

select college.cname, state, gpa       
  from college, apply, student
 where college.cname = apply.cname
   and apply.sid = student.sid
   and gpa >= all (select gpa 
                     from student,apply
                    where student.sid = apply.sid
   and apply.cname = college.cname);

我想知道如何创建查询以查找与申请人的最低gpa配对的大学

我知道这可以按如下方式完成

select college.cname, state, gpa       
  from college, apply, student
 where college.cname = apply.cname
   and apply.sid = student.sid
   and gpa = (select min(gpa) from student);

但是我该怎么做,而不使用 min

4

1 回答 1

0
select college.cname,state,gpa       
from college c
    join apply a On a.cname = c.cname 
    join student s On s.sid = apply.sid
where Not exists(select * from student 
                 Where gpa < s.gpa);
于 2013-03-22T03:29:30.447 回答