天天看点

Oracle 取Group By 第一条

select 查询内容 from

(

  select row_number() over(partition by 分组字段 order by 排序字段) as rn , 查询字a,查询字段b..

     from  表1,表2 where 条件

) where rn = 1 ;

select 查询内容 from

(

  select row_number() over(partition by 分组字段 order by 排序字段) as xuhao , 查询字a,查询字段b..

     from  表1 left join 表2 on 条件

) where xuhao = 1

继续阅读