Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1ToYQ5-0006jB-8j for pgsql-sql@arkaria.postgresql.org; Fri, 28 Dec 2012 11:48:09 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1ToYQ4-0004gd-Pt for pgsql-sql@arkaria.postgresql.org; Fri, 28 Dec 2012 11:48:08 +0000 Received: from makus.postgresql.org ([98.129.198.125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1ToYQ3-0004gY-TG for pgsql-sql@postgresql.org; Fri, 28 Dec 2012 11:48:08 +0000 Received: from mail-pa0-f44.google.com ([209.85.220.44]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1ToYQ2-0005Q7-M3 for pgsql-sql@postgresql.org; Fri, 28 Dec 2012 11:48:07 +0000 Received: by mail-pa0-f44.google.com with SMTP id hz11so6007042pad.3 for ; Fri, 28 Dec 2012 03:48:05 -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=bGFQi3KjxXnZzuS/4x6R7xLy7jZGpJvFjb7xLBENKdg=; b=rPxtjz+tbwoXqMJ8wn1IYaFc4zHKUVWKehwLmpUSdHHI3GydjQ6LH2e2NxDWK46T5j 6pTxW5c3OgAmILoSk5tIkQyPiKdOPaQ8Oxl1uw8j0ay179DlKkXYthpibRQ8GFy9WUHm nTkC5ZQttjJDcNA66xoPG3T/M0gaR2CrBLTzL2z5aNvHF8BsfMfUo1SRIZeyZ1umHots Te0TAohyTk7N9N0FMptgtIuIOwN/A3bpuep75X3mhDZvPHRlE+qqMdcZTJSWMsUUo6Eg DDJxQsVpY4Qp/vGKRPbbBJ3QSH5h/K9wqwC4yezTKl0yG/AtUrpyvDZEumlqfnZ9U3Ej h9OQ== Received: by 10.68.241.133 with SMTP id wi5mr103587757pbc.48.1356695285919; Fri, 28 Dec 2012 03:48:05 -0800 (PST) References: <-676946400807045909@unknownmsgid> From: Anton Gavazuk In-Reply-To: Mime-Version: 1.0 (1.0) Date: Fri, 28 Dec 2012 12:48:06 +0100 Message-ID: <-316905958645820213@unknownmsgid> Subject: Re: sql basic question To: Antonio Parrotta Cc: "pgsql-sql@postgresql.org" Content-Type: multipart/alternative; boundary=047d7b339cd595efc504d1e83c35 X-Pg-Spam-Score: -2.6 (--) 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 --047d7b339cd595efc504d1e83c35 Content-Type: text/plain; charset=ISO-8859-1 Antonio, but then you can do join between minmax select and source table by distance and get required columns... Thanks, Anton On Dec 28, 2012, at 12:43, Antonio Parrotta wrote: Hi Anton, I need column LABEL and ID as well. By grouping on SIDE these column cannot be included in the query. Thanks - Antonio On 28 December 2012 12:38, Anton Gavazuk wrote: > 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 > > --047d7b339cd595efc504d1e83c35 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Antonio,

=A0but then you can do join between minmax select and source table= by distance and get required columns...

Thanks,
Anton

On Dec 28, 2012, at 12:43, Antonio Parrotta <antonioparrotta@gmail.com> wrote:

=
Hi Anton,

I need column LABEL =A0and ID as well. By grouping on SIDE these column can= not be included in the query.

Thanks
- Antonio


On 28 December 2012 12:38, Anton Gavazuk= <antongavazuk@gmail.com> wrote:
Do the child Select min, max from... Group by= side

Then you can do whatever is required...
<= br>Thanks,
Anton

On Dec 28, = 2012, 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

--047d7b339cd595efc504d1e83c35--