Question

 SELECT       name, address1, address2, address3, city, state, zip, faxnum, phonenum, emailaddress, 
  odbcadmin.fn_calDist(- 0.03715491813985, 0.9178158214586024, long * 0.0174532925, lat * 0.0174532925) 
  AS distances
  FROM       dbo.Customer 
  WHERE     (odbcadmin.fn_calDist(- 0.03715491813985, 0.9178158214586024, long * 0.0174532925, lat * 0.0174532925) <= 150)
  ORDER BY distances

all this code is doing is fetching the distances and then showing them in a microsoft sql table in ascending order and also it has a condition that says only the distances within 150 miles are shown but i have no clue how to round in sql

Was it helpful?

Solution

Use ROUND(number , digits)

SELECT       name, address1, address2, address3, city, state, zip, faxnum, phonenum, emailaddress, 
  ROUND(odbcadmin.fn_calDist(- 0.03715491813985, 0.9178158214586024, long * 0.0174532925, lat * 0.0174532925) ,2)
  AS distances
  FROM       dbo.Customer 
  WHERE     (ROUND(odbcadmin.fn_calDist(- 0.03715491813985, 0.9178158214586024, long * 0.0174532925, lat * 0.0174532925),2) <= 150)
  ORDER BY distances`
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top