Re: Am I crazy or is this SQL not possible

Поиск
Список
Период
Сортировка
От Yasir Malik
Тема Re: Am I crazy or is this SQL not possible
Дата
Msg-id Pine.NEB.4.64.0606011409360.758@pink-elephant.cs.stevens-tech.edu
обсуждение исходный текст
Ответ на Am I crazy or is this SQL not possible  ("Collin Peters" <cadiolis@gmail.com>)
Ответы Re: Am I crazy or is this SQL not possible  (Rod Taylor <pg@rbt.ca>)
Re: Am I crazy or is this SQL not possible  ("Aaron Bono" <aaron.bono@aranya.com>)
Re: Am I crazy or is this SQL not possible  ("Aaron Bono" <aaron.bono@aranya.com>)
Список pgsql-sql
> 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_historybh2);
 

This reminds me of an interview question:  I was asked how to get a 
maximum column from a table without using max.  How would you do that?

Thanks,
Yasir


В списке pgsql-sql по дате отправления:

Предыдущее
От: "Aaron Bono"
Дата:
Сообщение: Re: Am I crazy or is this SQL not possible
Следующее
От: Yasir Malik
Дата:
Сообщение: Re: Am I crazy or is this SQL not possible