|
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-)
Navigation:
[Reply to this message]
|