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
select * from tname where rowid= (select max(rowid) from tname group by col1,col2);不知道是不是这个意思。
min(rowid) 都不一定是第一条记录,没规律分配
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;
名称 空? 类型
----------------------------------------- -------- ----------------------------
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
(select max(rowid) from tname group by col1,col2);不知道是不是这个意思。
--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;