pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Anton Gavazuk <antongavazuk@gmail.com>
To: Antonio Parrotta <antonioparrotta@gmail.com>
Cc: pgsql-sql@postgresql.org <pgsql-sql@postgresql.org>
Subject: Re: sql basic question
Date: Fri, 28 Dec 2012 12:38:23 +0100
Message-ID: <-676946400807045909@unknownmsgid> (raw)
In-Reply-To: <CAByPMP+g1gWSb3=tkCGRXruf-xvwgGOX_-tkDJva9Sx_1oSxYQ@mail.gmail.com>
References: <CAByPMP+g1gWSb3=tkCGRXruf-xvwgGOX_-tkDJva9Sx_1oSxYQ@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-sql>

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 <antonioparrotta@gmail.com>
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

view thread (8+ messages)  latest in thread

Message-ID: <-676946400807045909@unknownmsgid>
Permalink:  ../-676946400807045909@unknownmsgid/
Also on:    postgresql.org/message-id/-676946400807045909@unknownmsgid

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: antongavazuk@gmail.com, antonioparrotta@gmail.com
  Subject: Re: sql basic question
  In-Reply-To: <-676946400807045909@unknownmsgid>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox