Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 8EBA1633BC1 for ; Wed, 1 Apr 2009 11:57:50 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 40187-08 for ; Wed, 1 Apr 2009 11:57:36 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from yx-out-2324.google.com (yx-out-2324.google.com [74.125.44.30]) by mail.postgresql.org (Postfix) with ESMTP id BBDA2632D93 for ; Wed, 1 Apr 2009 11:57:45 -0300 (ADT) Received: by yx-out-2324.google.com with SMTP id 8so38423yxm.73 for ; Wed, 01 Apr 2009 07:57:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=J3y9bnAhBsQUlal0w72M/gXdSCQW/1y4i8ILQkGEssc=; b=NsyMxhHZdusoruAObNu7HOXkzjMDaEVPEYSyHfRAOJAU7oI803DEF6IjVLtBa7amSL j00ILVVwcvdPNi/XCG3HFB72+D6eswTU0CgqAn5nAHOXZYXYxPZ3DzKARqUzx6V52Wsr OL0LLSnstSBzP2SxUoYuF7PQCBmlZ51/7//PY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=AnnOCshJaiKTdD2eIZGniiDjeCeerkDgjFtaI1D+ldL+bA7YsdqTWJulioi9H6Nsfz bxEy0eaYarv7BuW8UW/U+xg4PAxHQmC9hWxQNz/0T4oAtMXdeEbBj2GX/UkzbG+Z4hFg k1pXhrdTN1H5vntf4VxTR970WLL99wbpkyRGc= MIME-Version: 1.0 Received: by 10.100.208.8 with SMTP id f8mr6579726ang.42.1238597864066; Wed, 01 Apr 2009 07:57:44 -0700 (PDT) In-Reply-To: <49CCC24A.90800@vivawasser.de> References: <49CA6121.8090704@vivawasser.de> <49CCC24A.90800@vivawasser.de> Date: Wed, 1 Apr 2009 07:57:38 -0700 Message-ID: <5d0f60990904010757t1d1dcbbbx1293e95e4850b31e@mail.gmail.com> Subject: Re: Add: Special sort querstion From: Dirk Jagdmann To: d.piekarski@vivawasser.de Cc: pgsql-sql@postgresql.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200904/1 X-Sequence-Number: 32347 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