Using ST_Distance would require two geometrical points , wherein i have a single 'geom' column with 50 geometrical records, for which i need to find the distance between the consecutive rows.
Say i need to find the distance between the first and second row, and then the second and third row and so on.
CREATE TABLE "gdata" ( device_ID text, data_ID bigserial NOT NULL, geom geometry )
[Created table]
[http://i.stack.imgur.com/gi9a3.png ]
I have used the following query to order.
select device_ID, geom from "gdata" ORDER BY device_ID
Therefore i obtain,
[http://i.stack.imgur.com/6RWig.png]
The expected output is a separate column named "distance" wherein, i calculate the distance between the first geometrical point and the second, then the second geometrical value and the third, and so on, for the succesive number of points in "geom".
Thanks in advance :) !
order by
- which requires some column that defines the sort order. Please edit your question and add the complete table definition (ascreate table
) some sample data (as formatted text) and the expected output based on that sample data. Ideally create an example at sqlfiddle.com – a_horse_with_no_namelag
as inlag(geom, 1) over (order by device_ID)
. – Eelke