SQL Server 2008 filters duplicate records by criteria

Source: Internet
Author: User

Usually we check the weight, and filter the duplicates according to a certain condition.

SELECT * FROM dbo. T_ecert A

where (A.ecertid) in (select Ecertid from T_ecert GROUP by Ecertid+idcard have count (*) > 1)


But what if you need to have multiple conditions?


Oracle can do this


SELECT * FROM dbo. T_ecert A

where (A.ecertid,a.idcard) in (select A.ecertid,a.idcard from T_ecert GROUP by Ecertid,idcard have count (*) > 1)


This solves the multi-conditional query, but SQL Server 2008 is not possible, but I think of a way to do this


SELECT * FROM dbo. T_ecert A

where (A.ecertid+a.idcard) in (select A.ecertid+a.idcard from T_ecert GROUP by Ecertid+idcard have count (*) > 1)


Multiple conditions can be combined into a single column, different data stitching out the data must be different, so the multi-condition sieve weight may be solved

This article is from the "Data Domain" blog, so be sure to keep this source http://charlist.blog.51cto.com/1616209/1697482

SQL Server 2008 filters duplicate records by criteria

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.