我将如何围绕这个SQL查询

时间:2013-10-02 08:08:22

标签: sql math rounding ceil

 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

所有这些代码所做的就是获取距离,然后按升序显示在microsoft sql表中,并且它还有条件说只显示150英里内的距离,但我不知道如何在sql中舍入

1 个答案:

答案 0 :(得分:1)

使用ROUND(数字数字

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`