GROUP BY 本来就只能得到每个组的一条纪录

解决方案 »

  1.   

    把Group By后的结果放在一个集合中,然后,用Loop语句取出第一条记录就可,这样应该可以实现吧。
      

  2.   

    14:54:20 jlanzpa817>desc groupby;
     名称                                      空?      类型
     ----------------------------------------- -------- ----------------------------
     A                                                  NUMBER
     B                                                  NUMBER
     C                                                  NUMBER14:54:29 jlanzpa817>select * from groupby;         1          1          1
             1          1          2
             1          2          1
             1          2          2
             1          3          1
             1          3          2
    已用时间:  00: 00: 00.30
    14:54:32 jlanzpa817>select * from groupby where rowid in (select a.rid from 
    14:54:34   2  ( select a,b,min(rowid) rid from groupby group by a,b ) a );         1          1          1
             1          2          1
             1          3          1
    已用时间:  00: 00: 00.11
      

  3.   

    select * from tname where rowid=
    (select max(rowid) from tname group by col1,col2);不知道是不是这个意思。
      

  4.   

    min(rowid) 都不一定是第一条记录,没规律分配
      

  5.   

    declare
    --type id_vrr is table of table.id%type index by binary_integer;
    cursor t_sor is
    select id,name,sum(..) num from table 
    group by id,name;
    begin
    for v_sor in t_sor loop
    if v_sor.id(第一次出现) then
    dbms_output.put_line(v_sor.id,v_sor.name,v_sor.num);
    end;
    end loop;
    end;