zwei1121

博客园 首页 新随笔 联系 订阅 管理

drop table test4


SELECT * INTO test4 from
(
select len(isnull(姓名,0)+isnull(性别,0)+isnull(年龄,0)+isnull(级别,0)+isnull(职务,0)+isnull(行业,0)+isnull([国家/省份],0)+isnull(城市,0)+isnull(企业名称,0)+isnull(电话,0)+isnull(手机,0)+isnull(EMail,0)) as t,ROW_NUMBER() OVER(ORDER BY len(isnull(姓名,0)+isnull(性别,0)+isnull(年龄,0)+isnull(级别,0)+isnull(职务,0)+isnull(行业,0)+isnull([国家/省份],0)+isnull(城市,0)+isnull(企业名称,0)+isnull(电话,0)+isnull(手机,0)+isnull(EMail,0)) DESC) AS 'ID'
,* from Test
where 姓名 IS NOT NULL AND 手机 IS NOT NULL and email IS NOT NULL
) as  tt

 

delete   test4
where   id   not   in
(
select   min(id)   from   test4  
group   by   姓名,手机,EMail)

 

WITH   b AS ( SELECT   ROW_NUMBER() OVER ( PARTITION BY 姓名,手机,email ORDER BY id asc ) AS rn,
                        *
               FROM     test4
             )
    DELETE  FROM b
    WHERE   rn > 1

 

Delete T From
(Select Row_Number() Over(Partition By 姓名,手机,email order By id asc) As RowNumber,* From test4) T
Where T.RowNumber > 1

 

SELECT 姓名,手机,email,count(*) from test4
GROUP BY 姓名,手机,email
HAVING count(*)>1

posted on 2012-08-01 11:23  zwei  阅读(235)  评论(0编辑  收藏  举报