X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 8426E9FA5C8 for ; Thu, 1 Jun 2006 15:42:35 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 50340-03 for ; Thu, 1 Jun 2006 15:42:31 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.169]) by postgresql.org (Postfix) with ESMTP id E0CB69FA040 for ; Thu, 1 Jun 2006 15:42:30 -0300 (ADT) Received: by ug-out-1314.google.com with SMTP id a2so201587ugf for ; Thu, 01 Jun 2006 11:42:29 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:sender:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=QmUXba5P75x8XLDkL/HOoth5dGPP2ShwjLroLc5+gunBPI21HRGxYBzz3jOI++CC8EUNj5jgGp9Yip7OBfprUutcTgBq8u5Ozz4/Df/w19HGTm5IgXNcmHZBoddDu6Sn5H5gA+8xQyDrdWz2XBLeKkGRAiogzwyKCpJIMDCAqyo= Received: by 10.66.252.4 with SMTP id z4mr33342ugh; Thu, 01 Jun 2006 11:42:29 -0700 (PDT) Received: by 10.67.20.12 with HTTP; Thu, 1 Jun 2006 11:42:29 -0700 (PDT) Message-ID: Date: Thu, 1 Jun 2006 13:42:29 -0500 From: "Aaron Bono" To: PostgreSQL Subject: Fwd: Stalled post to pgsql-sql In-Reply-To: <54223ebf21d014c0641a385526e8ab37330e465c@postgresql.org> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <54223ebf21d014c0641a385526e8ab37330e465c@postgresql.org> X-Google-Sender-Auth: 8047160c1c5751b5 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/48 X-Sequence-Number: 25284 I think this approach will only work if each broadcast_id has the same maximum date_sent value. You really need to do the group by in a sub-query to bring the broadcast_id together with the max date_sent. -Aaron Bono On 6/1/06, Yasir Malik wrote: > > What I would like to do is simply get the last date_sent and it's > > status for every broadcast. I can't do a GROUP BY because I can't put > > an aggregate on the status column. > > > > SELECT MAX(date_sent), status > > FROM broadcast_history > > GROUP BY broadcast_id > > > You could try the following: > select status > from broadcast_history bh > where bh.date_sent = > (select max(bh2.date_sent) > from broadcast_history bh2); >