Declare @Latitude Decimal(18,6), @Longitude Decimal(18,6) SELECT @latitude = Latitude, @Longitude = Longitude FROM VisaData.DBO.qvw_CityState WHERE City = @City AND State = @State SELECT TOP 20 JobID, jobtitle, company, companyid, city, state, Source, date, Left(snippet, 400) As snippet, Latitude, Longitude, CompanyID AS QDComID, VisaSponsor, url , (ROUND(SQRT(POWER(69.1 * (@Longitude - Opening.longitude) * COS(Opening.latitude / 57.3), 2) + POWER(69.1 * (@Latitude - Opening.latitude), 2)), 2)) AS Distance FROM Opening WHERE (ROUND(SQRT(POWER(69.1 * (@Longitude - Opening.longitude) * COS(Opening.latitude / 57.3), 2) + POWER(69.1 * (@Latitude - Opening.latitude), 2)), 2)) < 30 ORDER BY date desc