pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feed From: Mike Diehl <jdiehl@sandia.gov>
To: Fernando Hevia <fhevia@ip-tel.com.ar>
Cc: 'SQL Postgresql List' <pgsql-sql@postgresql.org>
Subject: Re: Problem with phone list.
Date: Thu, 16 Aug 2007 00:11:36 -0600
Message-ID: <200708160011.36868.jdiehl@sandia.gov> (raw )
In-Reply-To: <021801c7df7f$043d8610$8f01010a@iptel.com.ar >
References: <021801c7df7f$043d8610$8f01010a@iptel.com.ar >
Yup, that did it. I don't know why I made it harder than it had to be.
Thank you.
Mike.
On Wednesday 15 August 2007 02:58:22 pm Fernando Hevia wrote:
> Try this:
>
> Select *
> from view v1
> where duration = (select max(duration) from view v2 where v2.phone_number =
> v1.phone_number)
>
> You could get more than one call listed for the same number if many calls
> match max(duration) for that number.
>
>
> -----Mensaje original-----
> De: pgsql-sql-owner@postgresql.org [mailto:pgsql-sql-owner@postgresql.org]
> En nombre de Mike Diehl
> Enviado el: MiƩrcoles, 15 de Agosto de 2007 17:28
> Para: SQL Postgresql List
> Asunto: [SQL] Problem with phone list.
>
> Hi all.
>
> I've qot a problem I need to solve. I'm sure it's pretty simple; I just
> can't
> seem to get it, so here goes...
>
> I've got a table, actually a view that joins 3 tables, that contains a
> phone
>
> number, a unique id, and a call duration.
>
> The phone number has duplicates in it but the unique id is unique.
>
> I need to get a list of distinct phone numbers and the coorisponding
> largest
>
> call duration.
>
> I've got the idea that this should be a self-join on phone number where
> a.id<>b.id, but I just can't seem to get the max duration.
>
> Any hints would be much appreciated.
>
> Mike.
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Have you searched our list archives?
>
> http://archives.postgresql.org
--
Mike Diehl
view thread (7+ messages) latest in thread
Message-ID: <200708160011.36868.jdiehl@sandia.gov>
Permalink: ../200708160011.36868.jdiehl@sandia.gov/
Also on: postgresql.org/message-id/200708160011.36868.jdiehl@sandia.gov
copy link · copy postgr.es
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: jdiehl@sandia.gov, fhevia@ip-tel.com.ar
Subject: Re: Problem with phone list.
In-Reply-To: <200708160011.36868.jdiehl@sandia.gov>
* 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