Re: Am I crazy or is this SQL not possible

From: "Aaron Bono" <aaron(dot)bono(at)aranya(dot)com>
To: "Yasir Malik" <ymalik(at)cs(dot)stevens(dot)edu>
Cc: PostgreSQL <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Am I crazy or is this SQL not possible
Date: 2006-06-01 18:39:48
Message-ID: bf05e51c0606011139y26ae506cr8f40fbf12b399c3f@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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.

On 6/1/06, Yasir Malik <ymalik(at)cs(dot)stevens(dot)edu> 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);
>

==================================================================
Aaron Bono
President Aranya Software Technologies, Inc.
http://www.aranya.com We take care of your technology needs.
Phone: (816) 695-6071
==================================================================

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Aaron Bono 2006-06-01 18:42:29 Fwd: Stalled post to pgsql-sql
Previous Message Aaron Bono 2006-06-01 18:38:03 Re: Am I crazy or is this SQL not possible