Reply to Re: duplicate rows

Your name:

Reply:


Posted by IchBin on 08/04/06 19:14

ZeldorBlat wrote:
> Skafa wrote:
>> that's too obvious :-)
>> i also need to return the id.
>>
>> i found this to be working:
>>
>> select id, naam, prijs
>> from tblproduct p_outer
>> where prijs = (
>> select max(prijs)
>> from tblproduct p_inner
>> group by naam
>> having p_outer.naam = p_inner.naam
>> )
>>
>> altough, when two products have the same price, both are returned.
>>
>
> If you had two products with the same price then which id would you
> expect to be returned? You haven't specified, and hence you get both.
>

Have not tried this but this may do work without getting complicated:

select distinct max(price), name from products group by name;


Thanks in Advance...
IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us
__________________________________________________________________________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация