Re: Querying all months even if don't exist

Поиск
Список
Период
Сортировка
От A. Kretschmer
Тема Re: Querying all months even if don't exist
Дата
Msg-id 20070226153103.GB32428@a-kretschmer.de
обсуждение исходный текст
Ответ на Querying all months even if don't exist  (Robert Fitzpatrick <lists@webtent.net>)
Список 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 по дате отправления:

Предыдущее
От: "Chris Coleman"
Дата:
Сообщение: Re: how to sort an array and remove duplicate in plpgsql
Следующее
От: Richard Troy
Дата:
Сообщение: Re: Writing oracle/postgress generic SQL