0

我有两个查询,一个返回前 10 个最近的位置:

            DECLARE @center GEOGRAPHY

            SET @center = geography::Point(@Latitude, @Longitude, 4326)

            SELECT TOP 10
                [Physical_Address_Street]
                , [Physical_Address_Local]
                , [Physical_Address_State]
                , [Physical_Address_Zip]
                , [Phone_Number]
            FROM Gas_Stations
            WHERE Location_Type = 1
            ORDER BY @center.STDistance(Location) ASC

然后另一个将获得通过的纬度和经度的距离

            SELECT Location.STDistance(geography::Point(51, -2, 4326)) * 0.00062137119 
            FROM [MY_DB].[dbo].[Gas_Station]

这些都查询同一个表,那么我如何将它们组合起来并获得十个点中的每一个的距离?

4

1 回答 1

1
SELECT  TOP 10
        *,
        geography::Point(51, -2, 4326).STDistance(location) * 0.00062137119
FROM    gas_stations
WHERE   location_type = 1
ORDER BY
        @center.STDistance(location) ASC
于 2013-04-26T14:10:45.427 回答