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