Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TxlYE-0008S2-Vm for pgsql-sql@arkaria.postgresql.org; Tue, 22 Jan 2013 21:38:39 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1TxlYD-0000Vc-PO for pgsql-sql@arkaria.postgresql.org; Tue, 22 Jan 2013 21:38:37 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TxlYD-0000VX-5X for pgsql-sql@postgresql.org; Tue, 22 Jan 2013 21:38:37 +0000 Received: from mout.gmx.net ([212.227.15.19]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TxlYB-0007Mn-I0 for pgsql-sql@postgresql.org; Tue, 22 Jan 2013 21:38:36 +0000 Received: from mailout-de.gmx.net ([10.1.76.33]) by mrigmx.server.lan (mrigmx001) with ESMTP (Nemesis) id 0LaIM4-1TC5no2EMo-00m2Ae for ; Tue, 22 Jan 2013 22:38:34 +0100 Received: (qmail invoked by alias); 22 Jan 2013 21:38:34 -0000 Received: from mue-88-130-23-112.dsl.tropolys.de (EHLO [192.168.1.113]) [88.130.23.112] by mail.gmx.net (mp033) with SMTP; 22 Jan 2013 22:38:34 +0100 X-Authenticated: #14269776 X-Provags-ID: V01U2FsdGVkX1/OJIJ0ARjOjP0xVws2CjDIEiARZQvO1Aak7Bbyjc kPzo8VYevnJrbR Message-ID: <50FF0784.1070205@gmx.net> Date: Tue, 22 Jan 2013 22:41:24 +0100 From: Andreas User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130107 Thunderbird/17.0.2 MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: need some magic with generate_series() Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Y-GMX-Trusted: 0 X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org Hi I need a series of month numbers like 201212, 201301 YYYYMM to join other sources against it. I've got a table that describes projects: projects ( id INT, project TEXT, startdate DATE ) and some others that log events events( project_id INT, createdate DATE, ...) to show some statistics I have to count events and present it as a view with the project name and the month as YYYYMM starting with startdate of the projects. My problem is that there probaply arent any events in a month but I still need this line in the output. So somehow I need to have a select that generates: project 7,201211 project 7,201212 project 7,201301 It'd be utterly cool to get this for every project in the projects table with one select. Is there hope? -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql