pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Aaron Bono <aaron.bono@aranya.com>
To: Yasir Malik <ymalik@cs.stevens.edu>
Cc: PostgreSQL <pgsql-sql@postgresql.org>
Subject: Re: Am I crazy or is this SQL not possible
Date: Thu, 1 Jun 2006 13:39:48 -0500
Message-ID: <bf05e51c0606011139y26ae506cr8f40fbf12b399c3f@mail.gmail.com> (raw)
In-Reply-To: <Pine.NEB.4.64.0606011409360.758@pink-elephant.cs.stevens-tech.edu>
References: <df01c91b0606011043g61328d6habaee8fa037a5ccf@mail.gmail.com>
	<Pine.NEB.4.64.0606011409360.758@pink-elephant.cs.stevens-tech.edu>

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@cs.stevens.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
==================================================================



view thread (20+ messages)  latest in thread

Message-ID: <bf05e51c0606011139y26ae506cr8f40fbf12b399c3f@mail.gmail.com>
Permalink:  ../bf05e51c0606011139y26ae506cr8f40fbf12b399c3f@mail.gmail.com/
Also on:    postgresql.org/message-id/bf05e51c0606011139y26ae506cr8f40fbf12b399c3f@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: aaron.bono@aranya.com, ymalik@cs.stevens.edu
  Subject: Re: Am I crazy or is this SQL not possible
  In-Reply-To: <bf05e51c0606011139y26ae506cr8f40fbf12b399c3f@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox