【发布时间】:2013-10-22 07:10:30
【问题描述】:
我有一个 SQL Server 2012 位置表,其中有一列 geo 类型为 geography
我有一个链接到位置表的用户表
位置
locationId int
geo geography
用户
userId int
locationId int
我会知道该位置的 ID,并且我知道如何使用 stdistance 进行距离查询。但是,在查询中比较两个距离的最佳方法是什么。我可以使用子选择来做到这一点,但有没有更好的方法
子选择看起来像
select
suburb, state, postcode,
geo.STDistance((select geo from location where locationId = 47))/1000 kms
from location
order by kms desc
【问题讨论】:
标签: sql sql-server geography sqlgeography