How can I write a min query?

How can I write a min query?

am 21.02.2006 14:58:14 von laredotornado

Hello,

I have a table with vacation offier_id's and prices

OFFER_ID PRICE
--------------- --------
1 50.00
2 75.00
1 85.00
1 45.00
2 200.00

I want to write a query to return the offer_id with its lowest price.
The result of scanning the above data would be

OFFER_ID PRICE
--------------- ---------
1 45.00
2 75.00

Using MySQL 4, is there any way to write a single query to do this?
I'm using PHP 4 also.

Thanks, - Dave

Re: How can I write a min query?

am 21.02.2006 17:42:03 von zeldorblat

laredotornado@zipmail.com wrote:
> Hello,
>
> I have a table with vacation offier_id's and prices
>
> OFFER_ID PRICE
> --------------- --------
> 1 50.00
> 2 75.00
> 1 85.00
> 1 45.00
> 2 200.00
>
> I want to write a query to return the offer_id with its lowest price.
> The result of scanning the above data would be
>
> OFFER_ID PRICE
> --------------- ---------
> 1 45.00
> 2 75.00
>
> Using MySQL 4, is there any way to write a single query to do this?
> I'm using PHP 4 also.
>
> Thanks, - Dave

select OFFER_ID, min(PRICE)
from VACATIONS
group by OFFER_ID
from