ID NAME                 KECHENG                   SCORE
---------- -------------------- -------------------- ----------
         1 tom                  日语                         60
         2 tom                  java                        100
         3 tom                  法语                         83
         4 jack                 计算机                       90
         5 jack                 c                            85
         6 lili                 vb                           70
         7 lili                 vc                           80表名course  要求查出每门课程分数都大与80的人的名字。例如tom日语60,不符合要求。

解决方案 »

  1.   

    select a.* from  course a,
                   (select  NAME,min(SCORE)  from course 
                    group by  NAME
                    having min(SCORE) >= 80) b
    where a.NAME = b.NAME
      

  2.   

    select  *
    from course a 
    where not exists(select 1 from course b where b.name = a.name and b.score < 80)
      

  3.   

    第二种方法
    select * from 
    (
    select ID,NAME, KECHENG, SCORE,min(SCORE) over(partition by name order by SCORE) sou from course )
      where sou >= 80
      

  4.   

    SQL> edi
    已写入 file afiedt.buf  1  with tb as
      2  (select 1 id,'tom' name,'日语' kecheng,60 score from dual
      3  union all
      4  select 2,'tom','java',100 from dual
      5  union all
      6  select 3,'tom','法语',83 from dual
      7  union all
      8  select 4,'jack','计算机',90 from dual
      9  union all
     10  select 5,'jack','c',85 from dual
     11  union all
     12  select 6,'lili','vb',70 from dual
     13  union all
     14  select 7,'lili','vc',80 from dual)
     15  select distinct name from tb  where name in(select name from tb
     16* group by name having min(score)>80)
    SQL> /NAME
    ----
    jack
      

  5.   

    select name from course group by name having min(score) >=80
      

  6.   

     select name from student group by name having min(score)>=80
      

  7.   

    select min(c.name) from course c group by c.name having min(c.score)>80;