Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1ToYGj-0006Zj-Aq for pgsql-sql@arkaria.postgresql.org; Fri, 28 Dec 2012 11:38:29 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1ToYGi-0007z0-7z for pgsql-sql@arkaria.postgresql.org; Fri, 28 Dec 2012 11:38:28 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1ToYGh-0007yv-Dw for pgsql-sql@postgresql.org; Fri, 28 Dec 2012 11:38:27 +0000 Received: from mail-da0-f41.google.com ([209.85.210.41]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1ToYGe-0000eO-SA for pgsql-sql@postgresql.org; Fri, 28 Dec 2012 11:38:27 +0000 Received: by mail-da0-f41.google.com with SMTP id e20so4750672dak.14 for ; Fri, 28 Dec 2012 03:38:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=references:from:in-reply-to:mime-version:date:message-id:subject:to :cc:content-type; bh=WefrqwhQUDH5h+TR0bpl0Hue0/fv8Q05+BPJ28w/iG4=; b=O3OxqAB9lNoheLgd8dWZ+T7bikkV6vLXQLy0ukNv6FAYdCM6pUwz1Y5+4M9WUE+8Bl S9VzhXDPrfPvKX4Nu4KqGd3GDPiPgH/SbogJgRKYptSfyLDi/4ACJSvMVmjO2HCyAt4L mutOrU1i7Rs8GAKq6L2BwmYQC5tnxrixcO0rnjgAW0p+ewe1HaAzPNYiYaEMvAIUACQc taNhgkmog6b17w2iq0UoOOB6TIRwAIBaIs3b85nKXand+4X+IpZ6+W7amlDslwxum+Oy LRtQtOI2gsweifgce1P6OqFVJz4SnOCXY7Sdl82QRoDUq4UofJFsKla/JgJIy2LDPsod /qug== Received: by 10.66.73.165 with SMTP id m5mr98106038pav.78.1356694702567; Fri, 28 Dec 2012 03:38:22 -0800 (PST) References: From: Anton Gavazuk In-Reply-To: Mime-Version: 1.0 (1.0) Date: Fri, 28 Dec 2012 12:38:23 +0100 Message-ID: <-676946400807045909@unknownmsgid> Subject: Re: sql basic question To: Antonio Parrotta Cc: "pgsql-sql@postgresql.org" Content-Type: multipart/alternative; boundary=f46d042f9e00d0b06d04d1e819a3 X-Pg-Spam-Score: -2.7 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org --f46d042f9e00d0b06d04d1e819a3 Content-Type: text/plain; charset=ISO-8859-1 Do the child Select min, max from... Group by side Then you can do whatever is required... Thanks, Anton On Dec 28, 2012, at 12:23, Antonio Parrotta wrote: Hi All, I have this table: LABEL ID Distance SIDE "15"; 119006; 0.10975569030617; 1 "14"; 64054; 0.118448307450912; 0 "16"; 64055; 0.176240407317772; 0 "20"; 64057; 0.39363711745035; 0 "19"; 64056; 0.41205442839764; 1 "24"; 119007; 0.59758734628752; 0 What I want to achieve is a result table with min and max distance for each side, limiting to 2 (basically the boundaries of each SIDE) so the result should be: LABEL ID Distance SIDE "15"; 119006; 0.10975569030617; 1 "19"; 64056; 0.41205442839764; 1 "14"; 64054; 0.118448307450912; 0 "24"; 119007; 0.59758734628752; 0 Thanks a lot - Antonio y --f46d042f9e00d0b06d04d1e819a3 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Do the child Select min, = max from... Group by side

Then you can do whatever= is required...

Thanks,
Anton

On Dec 28, 201= 2, at 12:23, Antonio Parrotta <antonioparrotta@gmail.com> wrote:

Hi All,

I have t= his table:
LABEL =A0 =A0 ID =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Distance = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 SIDE
"15"; =A0 =A0 119006; =A0= =A0 =A00.10975569030617; =A0 =A0 =A0 =A01
"14"; =A0 =A0 64054= ; =A0 =A0 =A0 =A00.118448307450912; =A0 =A0 =A00
"16"; =A0 =A0 64055; =A0 =A0 =A0 =A00.176240407317772; =A0 =A0 = =A00
"20"; =A0 =A0 64057; =A0 =A0 =A0 =A00.39363711745035; =A0= =A0 =A0 =A00
"19"; =A0 =A0 64056; =A0 =A0 =A0 =A00.4120544283= 9764; =A0 =A0 =A0 =A01
"24"; =A0 =A0 119007; =A0 =A0 =A00.5975= 8734628752; =A0 =A0 =A0 =A00

What I want to achieve is a result table with min and max distance for = each side, limiting to 2 (basically the boundaries of each SIDE)

so the result should be:
LABEL= =A0 =A0ID =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Distance =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 SIDE
"15"; =A0 =A0 119006; =A0 =A0 =A00.10975569030617; =A0 =A0 = =A0 =A01
"19"; =A0 =A0 64056; =A0 =A0 =A0 =A00.41205442= 839764; =A0 =A0 =A0 =A01
"14"; =A0 =A0 64054; =A0 =A0 = =A0 =A00.118448307450912; =A0 =A0 =A00
"24"; =A0 =A0 11= 9007; =A0 =A0 =A00.59758734628752; =A0 =A0 =A0 =A00


Thanks a lot

- Antonio
y
--f46d042f9e00d0b06d04d1e819a3--