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--删除最小的IDdelete 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
)

相关内容推荐