我有一张桌子
emp checking saving cd contact type
tom 100.00 100.00 100.00 no x
tom 100.00 100.00 100.00 yes NULL
bob 200.00 200.00 200.00 no z
bob 200.00 200.00 200.00 yes NULL
mike 250.00 100.00 50.00 yes NULL
alice 500.00 210.00 10.00 yes NULL
期待结果
emp checking saving cd contact type
tom 100.00 100.00 100.00 no x
bob 200.00 200.00 200.00 no z
mike 250.00 100.00 50.00 yes NULL
alice 500.00 210.00 10.00 yes NULL
我的询问
select x.*
from (select *,
row_number() over (partition by emp order by type ) as seqnum
from table1
) x
where seqnum = 1
我的目标是删除重复记录。如果只有 2 条记录相同,并且在联系方式为“是”时需要删除。该查询删除了所有“否”并且看起来不正确。不知道我在这里想念什么? 感谢您的帮助。
select x.*
from (select *,
row_number() over (partition by emp, checking, saving, cd order by type
) as seqnum
from table1
) x
where seqnum = 1
该窗口仅依赖员工 ID。 如果您向分区添加其他条件,则可以更改组的粒度。