Re: Querying all months even if don't exist - Mailing list pgsql-general

From A. Kretschmer
Subject Re: Querying all months even if don't exist
Date
Msg-id 20070226153103.GB32428@a-kretschmer.de
Whole thread Raw
In response to Querying all months even if don't exist  (Robert Fitzpatrick <lists@webtent.net>)
List pgsql-general
am  Mon, dem 26.02.2007, um 10:10:45 -0500 mailte Robert Fitzpatrick folgendes:
> I have a query that pulls totals for the month and from there I am
> building a crosstab to show all months. My dilemma is that sometimes
> there is no data for a month and the crosstab becomes skewed. I made a
> table with all the 12 months in it and joined to the query in my view to

Try:

select ('2007-01-01'::date+(s||'month')::interval)::date from generate_series(0,11)s;


to generate a list of all month in this year. You can use this to join
to other tables.


Andreas
--
Andreas Kretschmer
Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID:   0x3FFF606C, privat 0x7F4584DA   http://wwwkeys.de.pgp.net

pgsql-general by date:

Previous
From: "Chris Coleman"
Date:
Subject: Re: how to sort an array and remove duplicate in plpgsql
Next
From: Richard Troy
Date:
Subject: Re: Writing oracle/postgress generic SQL