Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TxljG-0000Sq-Dx for pgsql-sql@arkaria.postgresql.org; Tue, 22 Jan 2013 21:50:02 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1TxljF-00025q-FB for pgsql-sql@arkaria.postgresql.org; Tue, 22 Jan 2013 21:50:01 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TxljE-00025k-It for pgsql-sql@postgresql.org; Tue, 22 Jan 2013 21:50:00 +0000 Received: from mout.web.de ([212.227.15.4]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TxljA-0007ZX-Qd for pgsql-sql@postgresql.org; Tue, 22 Jan 2013 21:49:59 +0000 Received: from [10.0.1.5] ([213.61.228.214]) by smtp.web.de (mrweb003) with ESMTPSA (Nemesis) id 0LoYWI-1THZMH3Cxu-00gtYV; Tue, 22 Jan 2013 22:49:55 +0100 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 6.2 \(1499\)) Subject: Re: need some magic with generate_series() From: jan zimmek In-Reply-To: <50FF0784.1070205@gmx.net> Date: Tue, 22 Jan 2013 22:49:56 +0100 Cc: pgsql-sql@postgresql.org Content-Transfer-Encoding: quoted-printable Message-Id: <1B56ACCA-3259-4AF6-9EBA-7045E261B18F@web.de> References: <50FF0784.1070205@gmx.net> To: Andreas X-Mailer: Apple Mail (2.1499) X-Provags-ID: V02:K0:NJvRLOWyM8ORbNTbzm4vo+eDX2yJ6MeoZogvtC0fR1i Qb+gPFd5VriXHsK9haAu1kiZ+s1KUbGb6XHfV26Lbh/RFUAsgA mnu85Amvr9SyG4fK0R4Oz7KjfN3OOFB7i5qPw8LfHkMyyGvOeX TSy/VZXboilo5ru2W5r6mQ6sy+/osPNO22org9UDAsUSLvxVMd E+IPbUR8zFsnQf4tnjqjw== 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 andreas, this might give you an idea how to generate series of dates (or other datat= ypes): select g, (current_date + (g||' month')::interval)::date from generate_seri= es(1,12) g; regards jan Am 22.01.2013 um 22:41 schrieb Andreas : > Hi > I need a series of month numbers like 201212, 201301 YYYYMM to join othe= r sources against it. >=20 > I've got a table that describes projects: > projects ( id INT, project TEXT, startdate DATE ) >=20 > and some others that log events > events( project_id INT, createdate DATE, ...) >=20 > to show some statistics I have to count events and present it as a view w= ith the project name and the month as YYYYMM starting with startdate of the= projects. >=20 > 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: >=20 > project 7,201211 > project 7,201212 > project 7,201301 >=20 > It'd be utterly cool to get this for every project in the projects table = with one select. >=20 > Is there hope? >=20 >=20 > --=20 > Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-sql --=20 Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql