34,590
社区成员
发帖
与我相关
我的任务
分享
select * from tbl_journal A inner join
(select Period, LegalEntity,ino_id,BUZEI from tbl_Journal where period>'201405'
group by Period,LegalEntity,ino_id,BUZEI having COUNT(*)>1 ) B
ON A.Period=b.Period and a.LegalEntity=b.LegalEntity and a.ino_id =b.ino_id and a.BUZEI=b.BUZEI
order by a.Period, a.LegalEntity, a.ino_id, a.BUZEI
DELETE T
FROM(
SELECT *
,ROW_NUMBER()OVER(PARTITION BY Period,LegalEntity,ino_id,BUZEI ORDER BY 主键)RN
FROM tbl_journal
)T WHERE RN>1
主键换成你的主键DELETE t
FROM
(SELECT *,ROW_NUMBER() OVER(PARTITION BY Period
,LegalEntity
,ino_id
,BUZEI ORDER BY Period) AS Row FROM tbl_journal
) AS t
WHERE Row>1