Search Postgresql Archives

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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 1/23/07, Jorge Godoy <jgodoy@xxxxxxxxx> 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/

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux