Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 0ED9C635745 for ; Wed, 1 Apr 2009 11:58:03 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 82674-04-2 for ; Wed, 1 Apr 2009 11:58:01 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-qy0-f115.google.com (mail-qy0-f115.google.com [209.85.221.115]) by mail.postgresql.org (Postfix) with ESMTP id 57C056354DA for ; Wed, 1 Apr 2009 11:57:59 -0300 (ADT) Received: by qyk13 with SMTP id 13so155146qyk.15 for ; Wed, 01 Apr 2009 07:57:57 -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=fmjwc95W/QPzjVjSQmJTCjbUae8+3PYkZNTnbqWAOB+AsyhrPkITIu87vofQMgf0RH SyLI70+cH9Cr1mcosgI3RK8DAdfEmmFi8bYgGeT92X6dZAlrLBXiYmaPYyTP6DZzGrSn utsEIB5SrOAYZdIAJvi1gmwElwnBka7To17qo= 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=DXD6qyJtp4vLJPxcnosoF9GFtbZNJ7awlGtbmtiqo/hKX5Aa06KynUgTqxKnkZM/9k TO3LzR61gQxpGD616rkYqaiEU/9YBc8SgL16JhvAlQ87LaxSjcJAzQPKLeuDZQnugpy7 f96x1HIuV6rg5PnMG35kQXnG5TZmqhmpIHlSM= MIME-Version: 1.0 Received: by 10.231.10.68 with SMTP id o4mr1676560ibo.33.1238597877580; Wed, 01 Apr 2009 07:57:57 -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:57 -0700 Message-ID: <5d0f60990904010757r34294c99y96fae71cc5579415@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/2 X-Sequence-Number: 32348 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