Re: generate_series to return row that doesn't exist in

Поиск
Список
Период
Сортировка
От MaXX
Тема Re: generate_series to return row that doesn't exist in
Дата
Msg-id 200603242154.29175.bs139412@skynet.be
обсуждение исходный текст
Ответ на Re: generate_series to return row that doesn't exist in  (Scott Marlowe <smarlowe@g2switchworks.com>)
Список pgsql-sql
On Friday 24 March 2006 21:42, Scott Marlowe wrote:
> More than likely you need a left join and a case statement.
>
> select <selectlist>, case when a.date is null then 0 else a.date end
> from (select * from generate_series() -- magic to get dates goes here)
> as p left join maintable as a on (p.date=a.date);
>
> There may be some small syntax error in there, as I've not tested it.
> The relavent pages are:
>
> case:
> http://www.postgresql.org/docs/8.1/static/functions-conditional.html
>
> joins:
> http://www.postgresql.org/docs/8.1/static/queries-table-expressions.html
Perfect!!
Time to RTFM again...

Thanks,
-- 
MaXX


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

Предыдущее
От: Rod Taylor
Дата:
Сообщение: Re: Find min and max values across two columns?
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Custom type