Re: [SQL] list of all months

2010-03-16 Thread Jasen Betts
On 2010-03-08, query 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

Re: [SQL] list of all months

2010-03-15 Thread silly sad
It looks like a procedural problem. I would solve it in plpgsql. -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

Re: [SQL] list of all months

2010-03-15 Thread Dawid Kuroczko
On Mon, Mar 8, 2010 at 13:25, query wrote: > > 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 fo

Re: [SQL] list of all months

2010-03-15 Thread Petru Ghita
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 One approach could be: You build a table with month information over which you are willing to show data from another table. Then you just cross join your data table and the data in your month table. Here is some code I use for generating the table

Re: [SQL] list of all months

2010-03-15 Thread Garrett Murphy
I recently ran into the same issue and I resolved it by generating a table of nothing but months for the last 5 years: select TO_CHAR((current_date - interval '1 month' * a),'-MM') AS mm FROM generate_series(1,60,1) AS s(a) "2010-02" "2010-01" "2009-12" "2009-11" "2009-10" … T