Re: using generate_series to iterate through months

Поиск
Список
Период
Сортировка
От Bill Reynolds
Тема Re: using generate_series to iterate through months
Дата
Msg-id 7C0800F63CCF4149AC0FC5EE2A04122606154F9E@sr002-2k3exc.ateb.com
обсуждение исходный текст
Ответ на Re: using generate_series to iterate through months  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
Ok, it is Monday -:)  Thanks Tom!


-----Original Message-----
From: Tom Lane [mailto:tgl@sss.pgh.pa.us]
Sent: Monday, August 03, 2009 11:44 AM
To: Bill Reynolds
Cc: pgsql-general@postgresql.org
Subject: Re: [GENERAL] using generate_series to iterate through months

"Bill Reynolds" <Bill.Reynolds@ateb.com> writes:
> Ok, I'm a bit stumped on getting my group by query to work which
> iterates through a number of months that basically a generate_series
> provides for me.
> ...
> select DATE('2008-05-01') + interval (s.a??? ' months') as Month_of

No, you're confusing a syntax that's meant to handle literal constants
with something that's appropriate for computation.  What you want is

> select DATE('2008-05-01') + s.a * interval '1 month' as Month_of

that is, multiply the sequence output by a suitable interval constant.

            regards, tom lane

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

Предыдущее
От: Andreas Kretschmer
Дата:
Сообщение: Re: using generate_series to iterate through months
Следующее
От: Andrew Maracini
Дата:
Сообщение: \copy command error