MySQL Forums
Forum List  »  Newbie

Using the Min() function Source provided
Posted by: Jeff Strenge
Date: August 07, 2004 12:55PM

I need to find the shortest distance that is calculated on lines 2 and 3 of the SQL statement below. When I use SQL statement below it gives me all four records, with the calculated value as expect.

Select Building.Building_Name,
sqrt(pow((342506-Building_Location.Lat_North),2)
+pow((cos(342506)*(874104-Building_Location.Long_West)),2))
from Building inner join Building_Location on
Building.BuildingID=Building_Location.BuildingID
where Building_Location.CellID=31
group by Building_name

if I use the min() function I STILL get all four RECORDS all I want is the record with the Smallest calculated value.
Does anyone know what is wrong with the SQL statement below.

Select Building.Building_Name, the
MIN(sqrt(pow((342506-Building_Location.Lat_North),2)
+pow((cos(342506)*(874104-Building_Location.Long_West)),2)))
from Building inner join Building_Location on
Building.BuildingID=Building_Location.BuildingID
where Building_Location.CellID=31
group by Building_name

Thanks
for your helpful Solutions
Jeff

Options: ReplyQuote


Subject
Written By
Posted
Using the Min() function Source provided
August 07, 2004 12:55PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.