RE: Question about solving a query !

2002-10-09 Thread Jianliang Zhao
Here is a correct one to solve your problem: select b.city, b.name, b.numbeds, count(distinct a.numbeds) c from hospitals a, hospitals b where a.city = b.city and a.numbeds>=b.numbeds group by b.name, b.city, b.numbeds having c=1; -Original Message- From: Myoung-Ah KANG [mailto:[EMAIL P

RE: Question about solving a query !

2002-10-09 Thread Andrew Braithwaite
Is this what you're looking for? mysql> select city,name,max(numbeds) from hospitals group by city; +---+--+--+ | city | name | max(numbeds) | +---+--+--+ | Lyon | Tonkin | 300 | | Marseille | Clairval | 150

Re: Question about solving a query !

2002-10-09 Thread Michael T. Babcock
Myoung-Ah KANG wrote: >The query is: "For each city, what is the name of the hospital having the >highest number of beds ? ' . > >Select name From Hospital Where (city, numbeds) In >(Select city, MAX(numbeds) From Hospital Group By city); > > > "select name, city, max(numbeds) from