Advertisement

06.18.2007 at 12:20PM PDT, ID: 22641418
[x]
Attachment Details

Need help with query to identify items with duplicate entries

Asked by SteveB2175 in MS SQL Server

Tags: duplicate, items, query, field

I am trying to clean up a database that is suffering from sins of the past...

I have a Description field, and a DescriptionNumber field that should have a 1 to 1 relationship.  However due to the above mentioned sins, a single DescriptionNumber may have more than one description assigned to it.

For example
row #1 is     | 1 | Cardboard box | blah blah blah
Row #2 is    | 1 | Box, Cardboard | blah blah blah

I need a query that will return any DescriptionNumber that has more than one description associated with it.

I have written

SELECT DescriptionNumber, Description
FROM table
GROUP BY DescriptionNumber, Description
ORDER BY DescriptionNumber

This produces a grid which I can review to find duplicate DescriptionNumbers, but the list includes DescriptionNumbers with only a single entry, and it is overwhelming to review manually.

I tried adding  HAVING Count(DescriptionNumber) > 1 but that doesn't seem to work.

Thanks for any help.Start Free Trial
[+][-]06.18.2007 at 12:26PM PDT, ID: 19309768

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: MS SQL Server
Tags: duplicate, items, query, field
Sign Up Now!
Solution Provided By: gpompe
Participating Experts: 2
Solution Grade: A
 
 
[+][-]06.18.2007 at 01:39PM PDT, ID: 19310492

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32