表A如下
字段1      字段2    字段3
a           1        5
a           2        4
a           3        6
b           1        9
b           2        8
b           3        7求结果(字段1分组,字段2最小值):
a      1     5
b      1     9

解决方案 »

  1.   

    问这种问题的人真的,哎~~select 字段1,字段2,字段3 from (
    select 字段1,字段2,字段3,row_number() over(partition by 字段1 order by 字段2) rn  from a)
    where rn=1
      

  2.   

    select 字段1,min(字段2) ,字段3
    from A group by 字段1;
      

  3.   


    select A.* from A,(select 字段1,min(字段2) 字段4 from A group by 字段1) A2 where A.字段1=A2.字段1 and A.字段2=A2.字段4;