Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 721A529F0DA for ; Mon, 12 Mar 2012 15:07:32 -0300 (ADT) Received: from [76.14.161.106] (helo=newserver.jfcomputer.com) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1S79ec-0006PQ-PO for pgsql-sql@postgresql.org; Mon, 12 Mar 2012 18:07:31 +0000 Received: from localhost (unknown [127.0.0.1]) by newserver.jfcomputer.com (Postfix) with ESMTP id 21F28FC29 for ; Mon, 12 Mar 2012 18:07:18 +0000 (UTC) X-Virus-Scanned: amavisd-new at site Received: from newserver.jfcomputer.com ([127.0.0.1]) by localhost (linux-jfp8.site [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9iZ7oe7o-8mR for ; Mon, 12 Mar 2012 11:07:13 -0700 (PDT) Received: from linux-12.localnet (unknown [192.168.1.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: johnf@jfcomputer.com) by newserver.jfcomputer.com (Postfix) with ESMTPSA id 016505931 for ; Mon, 12 Mar 2012 11:07:13 -0700 (PDT) From: John Fabiani To: pgsql-sql@postgresql.org Subject: Re: crosstab Date: Mon, 12 Mar 2012 11:07:12 -0700 Message-ID: <4791988.YSRGgLD8kK@linux-12> User-Agent: KMail/4.7.2 (Linux/3.1.9-1.4-desktop; KDE/4.7.2; x86_64; ; ) In-Reply-To: References: <1374902.j7hCdyTH7B@linux-12> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Host-Lookup-Failed: Reverse DNS lookup failed for 76.14.161.106 (failed) X-Pg-Spam-Score: -1.1 (-) X-Archive-Number: 201203/39 X-Sequence-Number: 36434 select * from crosstab('select item_number::text, week_of::date, planned_demand::text from holding_table order by 1,2') as ct(row_name text, week_of date, planned text) The above does not work. What am I doing wrong? Johnf On Monday, March 12, 2012 06:01:21 PM Pavel Stehule wrote: > Hello > > maybe this article helps > http://stackoverflow.com/questions/3002499/postgresql-crosstab-query > > there are more ways > > Regards > > Pavel Stehule > > 2012/3/12 John Fabiani : > > Hi, > > I don't know if it because I'm as sick as dog or I'm just a plain idiot > > - most likely a little of both. > > > > Here is my table > > > > week_of date, > > item_number text, > > planned_demand integer. > > > > I have > > week_of item_number planned > > 2012-02-12 00005 200 > > 2012-02-19 00005 -30 > > 2012-02-26 00005 -16 > > > > I want to see > > > > item_number 2012-02-12 2012-02-19 2012-02-26 > > 00005 200 -30 -16 > > > > I actually have added fields but that should get me started. > > > > Thanks for help from an old man with a very bad cold. > > > > Johnf > > > > -- > > Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) > > To make changes to your subscription: > > http://www.postgresql.org/mailpref/pgsql-sql