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 2000 Forums
 SQL Server Development (2000)
 Deleting Duplicated Rows

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-10-09 : 09:20:43
Matt writes "I have a table that has headings of ID, Location, Item, Plant, MB, and Price. The ID is a primary key but holds no significance elsewhere in our database. There are duplicate entries in the Item column but each duplicate entry has a different price. What I need to do is determine the highest Price out of all the duplicated items and then only retain those rows. Let me show you a little of what I mean:


ID	Location	Item	Plant	MB	Price2
27035 149 7LXW7043773 S B 6.00
27036 149 7LXW7043783 S B 8.50
12357 91 7LXW7043783 S B 7.75
12364 91 7LYW6302522 S B 5.60
71991 300 7MKU7315921 S B 2.00
34004 158 7MKU7315921 S B 3.25



In the sample data I would need to pull out all distinct Items, and of the items where there are 2 or more entries, I need the one that has the highest price.

Thus giving:

ID	Location	Item	Plant	MB	Price2
27035 149 7LXW7043773 S B 6.00
27036 149 7LXW7043783 S B 8.50
12364 91 7LYW6302522 S B 5.60
34004 158 7MKU7315921 S B 3.25


Thank you."
   

- Advertisement -