我正在尝试构建一个商店定位器,但是在编写SQL语句时遇到了困难。目前为止,我有以下代码:
SELECT TOP 3 Custno
, ( 3959
* acos( cos( radians(36) )
* cos( radians( Latitude ) )
* cos( radians( Longitude ) - radians(120) )
+ sin( radians(120) ) * sin( radians( Latitude ) )
)
) AS distance
FROM Customers
ORDER BY distance
当我运行该语句时,我得到了以下结果:
Msg 0, Level 11, State 0, Line 0
A severe error occurred on the current command.
The results, if any, should be discarded.
然而,当我删除order by子句并将其更改为使用Custno时,查询可以正常工作。是什么导致了这个错误,我该如何避免它呢?