Re: show all record between two date after group by and aggrigation...

Поиск
Список
Период
Сортировка
От Chad Wagner
Тема Re: show all record between two date after group by and aggrigation...
Дата
Msg-id 81961ff50701230527v76016e67mce54bee992324c60@mail.gmail.com
обсуждение исходный текст
Ответ на Re: show all record between two date after group by and aggrigation...  (Jorge Godoy <jgodoy@gmail.com>)
Список pgsql-general
On 1/23/07, Jorge Godoy <jgodoy@gmail.com> wrote:
> select cal.date, coalesce(foo.x, 0) AS x
>  from (select (date_trunc('day', current_timestamp) + (s.s * interval '1
> day'))::date AS date
>          from generate_series(1,365) AS s) AS cal
> left join foo ON cal.date = foo.create_date;

Why not, for the date part, the simpler alternative:

SELECT CURRENT_DATE + s.s AS DATE FROM generate_series(1, 365) AS s;

That's one of the problems with having a couple dozen date/time functions ;).


--
Chad
http://www.postgresqlforums.com/

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

Предыдущее
От: George Weaver
Дата:
Сообщение: Re: Problems compiling from source
Следующее
От: "Brandon Aiken"
Дата:
Сообщение: Re: too many trigger records found for relation "item" -