X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 7EB4D52825 for ; Wed, 20 Jul 2005 09:47:10 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 62790-09 for ; Wed, 20 Jul 2005 12:47:05 +0000 (GMT) Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.192]) by svr1.postgresql.org (Postfix) with ESMTP id B210352867 for ; Wed, 20 Jul 2005 09:47:03 -0300 (ADT) Received: by zproxy.gmail.com with SMTP id 4so1406643nzn for ; Wed, 20 Jul 2005 05:47:07 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=g+xmmHfNKWw75R6SX+9utc7N88VhKVEdMO+k7WfL9CIiWCLywQjlPE9qWO5XLAhNNvmUylGbBszPytosiuckU2Vk/+jIhwqfI5X03DOfcsVpHRibnp1KEVOKGhW8DY502XMwOPYUyFBB/Rzxu3lxFeubij1PXTjTMwUEStDk3V8= Received: by 10.36.141.16 with SMTP id o16mr58358nzd; Wed, 20 Jul 2005 05:46:39 -0700 (PDT) Received: by 10.36.75.6 with HTTP; Wed, 20 Jul 2005 05:46:38 -0700 (PDT) Message-ID: Date: Wed, 20 Jul 2005 08:46:38 -0400 From: Lindsay Reply-To: Lindsay To: pgsql-sql@postgresql.org Subject: ids from grouped rows Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.024 tagged_above=0 required=5 tests=RCVD_BY_IP X-Spam-Level: X-Archive-Number: 200507/174 X-Sequence-Number: 22152 Lets say i do this: SELECT name, MAX(age) FROM Person GROUP BY name This will group people who have the same name together, and return the highest age for each group. I want to be able to find the id for the person with the highest age in each group - Ideally, it would be something like this=20 SELECT name, MAX(age), id_for_row_with_max_age FROM Person GROUP BY name Anyone know how to do this? Lindsay