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中舍入
答案 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`