X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.225.181]) by svr1.postgresql.org (Postfix) with ESMTP id 6AE43CB8F9 for ; Sun, 13 Jul 2003 07:47:09 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr5.postgresql.org [64.117.225.181]) (amavisd-new, port 10024) with ESMTP id 16575-02 for ; Sun, 13 Jul 2003 07:46:58 +0000 (GMT) Received: from rtlocal.trade-india.com (mail-relay.trade-india.com [203.196.129.235]) by svr1.postgresql.org (Postfix) with SMTP id B5FC0CB66E for ; Sun, 13 Jul 2003 04:46:34 -0300 (ADT) Received: (qmail 27246 invoked from network); 13 Jul 2003 07:54:45 -0000 Received: from unknown (HELO system67.trade-india-local.com) (unknown) by unknown with SMTP; 13 Jul 2003 07:54:45 -0000 From: Rajesh Kumar Mallah Organization: Infocom Network Limited To: "Ali Adams" , Subject: Re: help yourself by helping others Date: Sun, 13 Jul 2003 13:16:49 +0530 User-Agent: KMail/1.5.1 References: <001c01c2fa9b$5b91ec80$03000000@DELLPC> In-Reply-To: <001c01c2fa9b$5b91ec80$03000000@DELLPC> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200307131316.49667.mallah@trade-india.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200307/153 X-Sequence-Number: 14267 dear ali, something like select machine,date_part('day' , date) , sum(withdrawals) from Table where date_part('month' , date)='month in question' group by machine,date_part('day' , date) ; will give you agrregated withdrawals by machine and day, use the frontend language for formatting it. note that it will not display the days for which there has been no withdrawls. If u need to report them also 0 then create a table that holds 1 year of dates and left or right join the output of first query with it. exact query is not being provided , its just an idea. regds mallah. On Friday 04 Apr 2003 4:40 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 > > 4 1 02/01/2003 1102 > 5 2 02/01/2003 2102 > > 6 1 03/01/2003 1103 > 7 3 03/01/2003 3103 > > 8 2 04/01/2003 2104 > 9 4 04/01/2003 4104 > > And i would like to create a monthly withdrawals report as follows: > > Machine Day1 Day2 Day3 Day4 > .............................................. Day31 1 11 > 12 13 0 0 2 > 21 22 0 24 > 0 3 31 0 33 0 > 0 4 0 0 0 > 0 0 > > Can you please help? > > Many thanks in advance. > > Ali > > www.geocities.com/aliadams