select A,min(B) as B from tablename group by A order by b
select A ,min(B) B from table group by A
with tmp as ( select 'A' cola, 1 colb from dual union all select 'B' cola, 32 colb from dual union all select 'C' cola, 11 colb from dual union all select 'D' cola, 22 colb from dual union all select 'E' cola, 6 colb from dual union all select 'A' cola, 33 colb from dual union all select 'B' cola, 111 colb from dual union all select 'F' cola, 2 colb from dual ) select cola,min(colb) from tmp group by cola order by 2;COLA MIN(COLB) ---- ---------- A 1 F 2 E 6 C 11 D 22 B 32
create table testA( A varchar2(10), B number);
insert into testA select 'A',1 from dual union all select 'B',32 from dual union all select 'C',11 from dual union all select 'D',22 from dual union all select 'E',6 from dual union all select 'A',33 from dual union all select 'B',111 from dual union all select 'F',2 from dual;
select * from (select A,B,rank() over(partition by A order by B) n from testA) tt where tt.n<=1 order by tt.B;
group by A
order by b
from table
group by A
with tmp as
(
select 'A' cola, 1 colb from dual union all
select 'B' cola, 32 colb from dual union all
select 'C' cola, 11 colb from dual union all
select 'D' cola, 22 colb from dual union all
select 'E' cola, 6 colb from dual union all
select 'A' cola, 33 colb from dual union all
select 'B' cola, 111 colb from dual union all
select 'F' cola, 2 colb from dual
)
select cola,min(colb) from tmp
group by cola
order by 2;COLA MIN(COLB)
---- ----------
A 1
F 2
E 6
C 11
D 22
B 32
A varchar2(10), B number);
insert into testA
select 'A',1 from dual union all
select 'B',32 from dual union all
select 'C',11 from dual union all
select 'D',22 from dual union all
select 'E',6 from dual union all
select 'A',33 from dual union all
select 'B',111 from dual union all
select 'F',2 from dual;
select * from (select A,B,rank() over(partition by A order by B) n from testA) tt where tt.n<=1 order by tt.B;