Special sort querstion

From: Dominik Piekarski <d(dot)piekarski(at)vivawasser(dot)de>
To: pgsql-sql(at)postgresql(dot)org
Subject: Special sort querstion
Date: 2009-03-25 16:51:45
Message-ID: 49CA6121.8090704@vivawasser.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hello everyone,

the following query
SELECT id, start_lat, start_lng, end_lat, end_lng
FROM strecken
WHERE ST_Intersects(strecke, geomfromtext('POLYGON((
52.5204252 13.3169317,
52.5407887 13.3169317,
52.5407887 13.3534097,
52.5204252 13.3534097,
52.5204252 13.3169317
))')) ORDER BY id;
produces by coincidence the following desired result:

id start_lat start_lng end_lat end_lng
18074 52.5212087 13.3181119 52.5226187 13.3183479
18075 52.5226187 13.3183479 52.5237154 13.3189702
18076 52.5237154 13.3189702 52.5244204 13.3201289
18077 52.5244204 13.3201289 52.5248120 13.3217812
18095 52.5195701 13.3381855 52.5204710 13.3390224
18096 52.5204710 13.3390224 52.5213653 13.3393443
18097 52.5213653 13.3393443 52.5219529 13.3395588
18098 52.5219529 13.3395588 52.5223511 13.3400846
20293 52.5408279 13.3338833 52.5404625 13.3350205
20294 52.5404625 13.3350205 52.5395881 13.3385825
20295 52.5395881 13.3385825 52.5387398 13.3447623

Its desired because every single row end_lat and end_lng has the same
value as the next row's start_lat and start_lng field (except last one).
I would like to achieve the same result without using id column inside
"order by" clause. Is that possible? How would that query look like?

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message DM 2009-03-25 19:20:08 Can we load all database objects in memory?
Previous Message Steve Midgley 2009-03-25 15:49:20 Re: Alter Table/Indexing