Received: from eba-haus.de ([149.228.241.205]) by hub.org (8.10.1/8.10.1) with SMTP id e5G7ajI57180 for ; Fri, 16 Jun 2000 03:36:46 -0400 (EDT) Received: from kopo001 by eba-haus.de;Fri, 16 Jun 2000 07:28:47 GMT with Novell_GroupWise; Fri, 16 Jun 2000 09:28:47 +0200 Message-Id: X-Mailer: Novell GroupWise 5.5.2 Date: Fri, 16 Jun 2000 09:28:27 +0200 From: "Gerhard Dieringer" To: Cc: Subject: Antw: using max() aggregate Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Disposition: inline Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by hub.org id e5G7alI57186 X-Archive-Number: 200006/162 Louis-David Mitterrand - ldm@apartia.org - http://www.apartia.fr wrote: > 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, I didn't test it, but something like SELECT title,stopdate FROM auction WHERE stopdate = (SELECT max(stopdate) FROM auction); should work. -------- Gerhard