Received: from styx.apartia.int (postfix@dyn-1-1-238.Vin.dialup.oleane.fr [195.25.4.238]) by hub.org (8.10.1/8.10.1) with ESMTP id e5G5quI42847 for ; Fri, 16 Jun 2000 01:52:56 -0400 (EDT) Received: by styx.apartia.int (Postfix, from userid 1000) id 0CD554813; Fri, 16 Jun 2000 07:52:54 +0200 (CEST) Date: Fri, 16 Jun 2000 07:52:53 +0200 From: Louis-David Mitterrand To: pgsql-sql@postgresql.org Subject: using max() aggregate Message-ID: <20000616075253.B1105@styx> Reply-To: ldm@apartia.ch Mail-Followup-To: pgsql-sql@postgresql.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2i X-Archive-Number: 200006/161 Hello, I am trying to return the most recently updated record from a table: SELECT max(stopdate) FROM auction; and this works but only returns the timestamp, however if I try to get another column with the aggregate it fails: SELECT title,max(stopdate) FROM auction; ERROR: Attribute auction.title must be GROUPed or used in an aggregate function Ok, so I group it now: SELECT title,max(stopdate) FROM auction GROUP BY title; title | max ---------------+------------------------ dfsdfsdf | 2000-07-10 05:00:00+02 dssdfsdfsdfsf | 2000-07-09 16:00:00+02 sdfsdfsdfsdf | 2001-04-10 15:00:00+02 (3 rows) But the problem is that I now get three rows when I only want the max() item. How should I do it? Thanks in advance, -- Louis-David Mitterrand - ldm@apartia.org - http://www.apartia.fr "Logiciels libres : nourris au code source sans farine animale."