Eliminate duplicates in SQL query
Posted
by ewdef
on Stack Overflow
See other posts from Stack Overflow
or by ewdef
Published on 2010-05-06T23:46:00Z
Indexed on
2010/05/06
23:58 UTC
Read the original article
Hit count: 206
sql
|duplicates
i have a table with 6 fields. the columns are ID, new_id price,title,Img,Active. I have datawhich is duplicated for the price column. When I do a select i want to show only distinct rows where new_id is not the same. e.g.-
ID New_ID Price Title Img Active
1 1 20.00 PA-1 0X4... 1
2 1 10.00 PA-10 0X4... 1
3 3 20.00 PA-11 0X4... 1
4 4 30.00 PA-5 0X4... 1
5 9 20.00 PA-99A 0X4... 1
6 3 50.00 PA-55 0X4... 1
When the select statement runs, only rows with ID (1,4,9,6) should show. Reason being the new_ID with the higher price should show up. How can i do this?
© Stack Overflow or respective owner