I use PostgreSQL 9.5.3, PostGIS 2.2 and pgRouting 2.3.2.

I have the same problem as Shortest Path Dijkstra because I use the same data with the same columns but when I put

 SELECT seq, id1 AS node, id2 AS edge, cost, b.the_geom, b.osm_name FROM pgr_dijkstra('

            SELECT id,
                     length::double precision AS cost
                    FROM at_2po_4pgr',
            30, 60, false, false) a LEFT JOIN at_2po_4pgr b ON (a.id2 = b.id);

into SQL window I got

ERROR: column link "cost" is ambiguous

How do I change cost atrribute?

I made it using this code:

SELECT seq, id1 AS node, id2 AS edge, di.cost, geom_way, osm_name  FROM pgr_dijkstra(
'SELECT id, source, target, st_length(geom_way) as cost FROM aa_2po_4pgr',
23941, 24159, false, false  ) as di  JOIN aa_2po_4pgr  ON di.id2 = aa_2po_4pgr.id
  • change define which cost you want - a.cost probably – Ian Turton Feb 17 '17 at 14:46
  • Yes. I know that, but which query do I have to use? I'm completly green here. I checked my data with pgrouting plugin on QGIS and every works fine. I'm sad that there is no small window in this plugin which shows queriers that was made in QGIS. – bass Feb 17 '17 at 16:32
  • Ok, I made it by myself. – bass Feb 18 '17 at 14:44
  • 1
    The problem is that you have cost in at_2po_4pgr a and b, so the optimiizer doesn't know which one you are referring to. If you put a.cost or b.cost in the select, the error will go away. – John Powell Feb 19 '17 at 12:00

Browse other questions tagged or ask your own question.