码迷,mamicode.com
首页 > 数据库 > 详细

db2记录去重

时间:2017-11-08 13:26:10      阅读:236      评论:0      收藏:0      [点我收藏+]

标签:sel   let   having   item   date   日期   dex   select   sys   

--查出二码,归档日期,借据号重复的数据的条数

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记录去重

标签:sel   let   having   item   date   日期   dex   select   sys   

原文地址:http://www.cnblogs.com/revo/p/7803229.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!