pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Fernando Hevia <fhevia@ip-tel.com.ar>
To: 'Michael Glaesemann' <grzm@seespotcode.net>
To: 'Mike Diehl' <jdiehl@sandia.gov>
Cc: 'SQL Postgresql List' <pgsql-sql@postgresql.org>
Subject: Re: Problem with phone list.
Date: Thu, 16 Aug 2007 10:56:17 -0300
Message-ID: <022401c7e00d$379dbeb0$8f01010a@iptel.com.ar> (raw)
In-Reply-To: <904C5251-F9A7-4579-B083-F77DDB4D6EDC@seespotcode.net>

--- Michael Glaesemann wrote:

> SELECT DISTINCT ON (phone_number)
>      phone_number, call_duration, id
> FROM calls
> ORDER BY phone_number
>      , call_duration DESC;

Wasn't acquainted with "DISTINCT ON (column)". 
I found it to be many times faster than other suggestions using JOIN.

Cheers,
Fernando.






view thread (7+ messages)

Message-ID: <022401c7e00d$379dbeb0$8f01010a@iptel.com.ar>
Permalink:  ../022401c7e00d$379dbeb0$8f01010a@iptel.com.ar/
Also on:    postgresql.org/message-id/022401c7e00d$379dbeb0$8f01010a@iptel.com.ar

 · 

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: fhevia@ip-tel.com.ar, grzm@seespotcode.net, jdiehl@sandia.gov
  Subject: Re: Problem with phone list.
  In-Reply-To: <022401c7e00d$379dbeb0$8f01010a@iptel.com.ar>

* 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