Re: Building a "complex" select?

Поиск
Список
Период
Сортировка
От Scott Marlowe
Тема Re: Building a "complex" select?
Дата
Msg-id 1113843036.20921.500.camel@state.g2switchworks.com
обсуждение исходный текст
Ответ на Building a "complex" select?  (Bjørn T Johansen <btj@havleik.no>)
Ответы Re: Building a "complex" select?  (Bjørn T Johansen <btj@havleik.no>)
Список pgsql-general
On Mon, 2005-04-18 at 11:24, Bjørn T Johansen wrote:
> I need a select like this..:
>
> select ordre.id, ordre.desc, log_stop.stoptype from ordre left outer join log_stop on
> ordre.id = log_stop.ordreid where ordre.id = 22
>
> The problem is that I need to include "where log_stop.stoptype = 1". So if log_stop
> includes 3 rows with stoptype = 1 and ordreid = 22, my select should return 3 rows.
> Also, if log_stop includes 3 rows with stoptype = 1 and 2 rows with stoptype = 2, my
> select should still return 3 rows. And if there are 0 rows with stoptype = 1, my
> select should return 1 row.

Would this work?

select ordre.id, ordre.desc, log_stop.stoptype from ordre left outer join log_stop on
ordre.id = log_stop.ordreid where ordre.id = 22 AND COALESCE(log_stop.stoptype,1)=1



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

Предыдущее
От: Bjørn T Johansen
Дата:
Сообщение: Building a "complex" select?
Следующее
От: Bjørn T Johansen
Дата:
Сообщение: Re: Building a "complex" select?