Re: Add: Special sort querstion

From: Dirk Jagdmann <jagdmann(at)gmail(dot)com>
To: d(dot)piekarski(at)vivawasser(dot)de
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Add: Special sort querstion
Date: 2009-04-01 14:57:57
Message-ID: 5d0f60990904010757r34294c99y96fae71cc5579415@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

I think it can not be done with default PostgreSQL functions and
operators, because you must compare two different columns of two rows
depending which row is on either side of the "<" comparision.

But I think you can do this with the following steps:

1) create a new type as a 4-tupel of start_lat, end_lat, start_lng, end_lng.
2) write a comparison function for this type
3) write a SQL-Function to convert 4 values into your new type (for
example: ToMyType(start_lat, end_lat, start_lnd, end_lng) returns
MyType...)
4) use ToMyType in the order clause of your select

If this would work, I'm interested in a working example code :-)

--
---> Dirk Jagdmann
----> http://cubic.org/~doj
-----> http://llg.cubic.org

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Scott Marlowe 2009-04-01 15:08:26 Re: Add: Special sort querstion
Previous Message Dirk Jagdmann 2009-04-01 14:57:38 Re: Add: Special sort querstion