db2记录去重
Posted 有的事,必须自己去领悟~
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了db2记录去重相关的知识,希望对你有一定的参考价值。
--查出二码,归档日期,借据号重复的数据的条数
select default_index_item_id,record_date,index_yxdk_dkjjh,min(sys_org_id),max(sys_org_id), min(submit_time),max(submit_time),count(index_yxdk_id),
min(index_yxdk_id),max(index_yxdk_id)
from index_yxdk_tb
group by default_index_item_id,record_date,index_yxdk_dkjjh
having count(index_yxdk_id) > 1
--查看最小ID
select min(index_yxdk_id)
from index_yxdk_tb
group by default_index_item_id,record_date,index_yxdk_dkjjh
having count(index_yxdk_id) > 1
--删除最小的ID
delete from index_yxdk_tb where index_yxdk_id in (
select min(index_yxdk_id)
from index_yxdk_tb
group by default_index_item_id,record_date,index_yxdk_dkjjh
having count(index_yxdk_id) > 1
)
以上是关于db2记录去重的主要内容,如果未能解决你的问题,请参考以下文章