Received: from localhost (maia-2.hub.org [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 030B39FA671 for ; Thu, 16 Aug 2007 10:56:25 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 79533-01-6 for ; Thu, 16 Aug 2007 10:56:14 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from pyxis.powervt.com.ar (host3.powervt.com.ar [200.43.63.66]) by postgresql.org (Postfix) with ESMTP id 964439FA681 for ; Thu, 16 Aug 2007 10:56:20 -0300 (ADT) Received: from pcfhevia ([201.216.249.98]) by pyxis.powervt.com.ar (IPGroup Mail Server) with ESMTP id 1OT48953; Thu, 16 Aug 2007 10:56:18 -0300 From: "Fernando Hevia" To: "'Michael Glaesemann'" , "'Mike Diehl'" Cc: "'SQL Postgresql List'" Subject: Re: Problem with phone list. Date: Thu, 16 Aug 2007 10:56:17 -0300 Organization: IP-TEL Message-ID: <022401c7e00d$379dbeb0$8f01010a@iptel.com.ar> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 11 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3138 In-Reply-To: <904C5251-F9A7-4579-B083-F77DDB4D6EDC@seespotcode.net> Thread-Index: Acfff/eGovsm4Ho/TMKleBG3CQLAcAAiwUqw X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200708/141 X-Sequence-Number: 29079 --- 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.