Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Deleting nearly duplicate rows of data

Author  Topic 

bigrack
Starting Member

9 Posts

Posted - 2009-07-08 : 14:24:50
Hello,

Got a problem I can't solve. Take a Look at this data. I need to populate a new table with the exact same 4 fields shown below but with only one record for each UPC, Description and Region and it doesn't matter which Vendor. Is there a way to do this without cursors?

UPC | Description | Region | VendorID
111 | Widget | E | 25
111 | Widget | E | 32
222 | Gadget | E | 44
222 | Gadget | E | 46

Thank you in advance,
Keith

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-07-08 : 14:44:08
[code]
SELECT UPC ,Description , Region,MAX(VendorID )
FROM Yourtable
GROUP BY UPC ,Description , Region
[/code]
Go to Top of Page

bigrack
Starting Member

9 Posts

Posted - 2009-07-08 : 15:20:11
I'm embarrassed to say I didn't even think of something like this even though the data in vendorID is really text, I just put numbers in there because it was easier. I'm assuming I can still use this or something similar. Thank you.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-07-09 : 10:38:47
welcome
Go to Top of Page
   

- Advertisement -