X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.193]) by svr1.postgresql.org (Postfix) with ESMTP id 0E24CCC542 for ; Thu, 10 Jul 2003 09:41:29 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr1.postgresql.org [64.117.224.193]) (amavisd-new, port 10024) with ESMTP id 87076-03 for ; Thu, 10 Jul 2003 06:40:56 -0300 (ADT) Received: from anchor-post-31.mail.demon.net (anchor-post-31.mail.demon.net [194.217.242.89]) by svr1.postgresql.org (Postfix) with ESMTP id 77744CC21F for ; Thu, 10 Jul 2003 05:24:24 -0300 (ADT) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-31.mail.demon.net with esmtp (Exim 3.35 #1) id 19aWjE-000AOX-0V; Thu, 10 Jul 2003 09:24:36 +0100 Received: from localhost (localhost.localdomain [127.0.0.1]) by mainbox.archonet.com (Postfix) with ESMTP id EBB7916D61; Thu, 10 Jul 2003 09:24:34 +0100 (BST) Received: from client.archonet.com (client.archonet.com [192.168.1.16]) by mainbox.archonet.com (Postfix) with ESMTP id 8CEBC16D5D; Thu, 10 Jul 2003 09:24:32 +0100 (BST) Content-Type: text/plain; charset="iso-8859-1" From: Richard Huxton Organization: Archonet Ltd To: "Ali Adams" , Subject: Re: help yourself by helping others Date: Thu, 10 Jul 2003 09:24:36 +0100 User-Agent: KMail/1.4.3 References: <001c01c2fa9b$5b91ec80$03000000@DELLPC> In-Reply-To: <001c01c2fa9b$5b91ec80$03000000@DELLPC> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200307100924.37218.dev@archonet.com> X-Virus-Scanned: by AMaViS snapshot-20020531 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200307/127 X-Sequence-Number: 14241 On Friday 04 Apr 2003 12:10 pm, Ali Adams wrote: > Dear All, > > I am new to Relational Databases and SQL and my background in ODBs is > clouding my way to solving what seems to be a simple problem. I am sure > many of you have met it many times. > > OK, I have a table as follows: > > > ID Machine Date Withdrawals > 1 1 01/01/2003 1101 > 2 2 01/01/2003 2101 > 3 3 01/01/2003 3101 [snip] > And i would like to create a monthly withdrawals report as follows: > > Machine Day1 Day2 Day3 Day4............ Day31 Two options - either do it in your app or write a crosstab function. You can extract the day part of the month using: SELECT EXTRACT('day' FROM now()); You can find some crosstab functions in the contrib/tablefunc directory of = the=20 source distribution (or possibly as a package if installed as binary) --=20 Richard Huxton