我有SQL:pgRouting shortest_path得到潮頭osm_id值
SELECT osm_id, vertex_id
FROM ways
JOIN
(SELECT * FROM shortest_path('
SELECT gid AS id,
source::int4 AS source,
target::int4 AS target,
length::float8 AS cost
FROM ways',
7856,
18774,
false,
false)) AS route
ON
ways.gid = route.edge_id
order by vertex_id
它生產的是這樣的:
osm_id;vertex_id
5024380;6223
5024380;6224
5024380;6225
5024380;6226
175339584;6227
5024380;6230
5024380;6231
5024380;6232
38521651;6233
5024380;6234
你可以看到,osm_id不是唯一的。我neet osm_id
訂購vertex_id
。我怎樣才能得到唯一osm_id
值vertex_id
排序。我不需要vertex_id
列。只需要osm_id
。我嘗試了group by
條款,但這不起作用。休耕查詢:
SELECT distinct osm_id
FROM ways
JOIN
(SELECT * FROM shortest_path('
SELECT gid AS id,
source::int4 AS source,
target::int4 AS target,
length::float8 AS cost
FROM ways',
7856,
18774,
false,
false)) AS route
ON
ways.gid = route.edge_id
--group by osm_id
order by vertex_id
給出了錯誤:
ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list
LINE 21: order by vertex_id
^
********** Error **********
ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list
SQL state: 42P10
Character: 420
什麼表不vertex_id從何而來?方式或'路線'/ shortest_path子查詢?來自shortest_path子查詢的 – 2013-03-09 14:22:14
。 – Guntis 2013-03-09 14:30:35