1.单表查询,多条重复记录只取一条
select * from
(
select row_number() over(partition by 重复字段 order by 时间字段 倒序还是顺序) a1, a2.字段1,a2.字段2 from 表 a2
where 1=1
查询条件
)where a1 = 1
2.总结关键是表的去重,只取第一条语句:
(select * from (select rank() over(partition by bzdwcode order by dwcode desc) r,a.* from jl a) where r=1) f
用过第一种,第二种还没用过