sql 查询重复数据 删除重复数据

select SERVICE_ID,STANDARD_YEAR,count(*)
from DZBLPJ.INSURANCE_SERVER_ITEM  group by SERVICE_ID,STANDARD_YEAR
delete from DZBLPJ.INSURANCE_SERVER_ITEM a
where (SERVICE_ID,STANDARD_YEAR) in (select SERVICE_ID,STANDARD_YEAR
from DZBLPJ.INSURANCE_SERVER_ITEM  group by SERVICE_ID,STANDARD_YEAR having count(*) > 1)
and rowid not in (select min(rowid) from DZBLPJ.INSURANCE_SERVER_ITEM
group by SERVICE_ID,STANDARD_YEAR having count(*)>1)
DELETE 
FROM
    LCFYJTTZ c 
WHERE
    EXISTS (
        SELECT
            a.ROWID 
        FROM
            LCFYJTTZ a,
            (
            SELECT
                fdate,
                ffjdm,
                flcdm,
                ffytype,
                fgsbz,
                MIN( ROWID ) rid 
            FROM
                lcfyjttz 
            GROUP BY
                fdate,
                ffjdm,
                flcdm,
                ffytype,
                fgsbz 
            HAVING
                count( 1 ) > 1 
            ) b 
        WHERE
            a.FDATE = b.FDATE 
            AND a.FFJDM = b.FFJDM 
            AND a.FLCDM = b.FLCDM 
            AND a.ffytype = b.FFYTYPE 
            AND a.ROWID != b.rid
            AND c.ROWID = a.ROWID 
    )

上一篇:Calculate Mean and Standard Deviation of Data


下一篇:Visual Studio调试之断点技巧篇补遗