i am trying to find nearest stores and their longitude and latitude based on customer location (lon,lat) and populate in Google map. Here is a sample query would work in MySQL. Would this same query work in Salesforce? Do we have Radians function or equivalent function for Radians in salesforce? Moreover, is this possible to frame a query like this?
SELECT
`id`,
`name`,
ACOS( SIN( RADIANS( `latitude` ) ) * SIN( RADIANS( $fLat ) ) + COS( RADIANS( `latitude` ) )
* COS( RADIANS( $fLat )) * COS( RADIANS( `longitude` ) - RADIANS( $fLon )) ) * 6380 AS `distance`
FROM `stations`
WHERE
ACOS( SIN( RADIANS( `latitude` ) ) * SIN( RADIANS( $fLat ) ) + COS( RADIANS( `latitude` ) )
* COS( RADIANS( $fLat )) * COS( RADIANS( `longitude` ) - RADIANS( $fLon )) ) * 6380 < 10
ORDER BY `distance`
Any ideas?
Thanks, Baskaran