Re: list of all months - Mailing list pgsql-sql

From Jasen Betts
Subject Re: list of all months
Date
Msg-id hnnhfs$u3c$2@reversiblemaps.ath.cx
Whole thread Raw
In response to list of all months  ("query" <search2006@rediffmail.com>)
List pgsql-sql
On 2010-03-08, query <search2006@rediffmail.com> wrote:
> --=_484d28810a276e7b5e461f0328ee205f
> Content-Transfer-Encoding: 7bit
> Content-Type: text/plain; charset="UTF-8"
>
> Hi,
>
> I want to display data for all days in a month even if no data
> exists for that month. Some of the days in a month might not have any
> data at all. With normal query, we can display days only if data
> exists.But I want to display rows for all days in a month with blank
> data for non-existing day in database.
>
> How can this be achieved ?
>  

an outer join to (select FIRST_DAY_OF_MONTH + generate_series(1,DAYS_IN_MONTH) -1 )
where the date columns match

FIRST_DAY_OF_MONTH and DAYS_IN_MONTH are to be replaced (by you) with the
apropriate expressions by some means, possibly date arithmetic.





pgsql-sql by date:

Previous
From: Marcin Krawczyk
Date:
Subject: pgAgent stats
Next
From: Richard Huxton
Date:
Subject: Re: installing uuid generators