X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E070BDA819 for ; Fri, 21 Oct 2005 14:03:07 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 87725-06 for ; Fri, 21 Oct 2005 17:03:04 +0000 (GMT) Received: from sccrmhc11.comcast.net (sccrmhc11.comcast.net [204.127.202.55]) by svr1.postgresql.org (Postfix) with ESMTP id 8828BDA8B3 for ; Fri, 21 Oct 2005 12:32:12 -0300 (ADT) Received: from [192.168.1.100] (pcp0010098181pcs.levtwn01.pa.comcast.net[69.242.41.192]) by comcast.net (sccrmhc11) with ESMTP id <2005102115321001100rt2efe>; Fri, 21 Oct 2005 15:32:10 +0000 Message-ID: <435909FD.5040904@comcast.net> Date: Fri, 21 Oct 2005 11:32:13 -0400 From: Jerry Blumenthal Reply-To: jerry@blumenthalsoftware.com User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Aggregate versus lineitem report Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.868 required=5 tests=[DNS_FROM_RFC_POST=1.376, DNS_FROM_RFC_WHOIS=0.492] X-Spam-Level: * X-Archive-Number: 200510/273 X-Sequence-Number: 23126 How do you get a report that lists items and then produces a sum at the end. Like this: name date amount1 amount2 name date amount1 amount2 name date amount1 amount2 totals sum(amount1) sum(amount2) The sql command I am using now is SELECT SUM(Tcode.T_amount) Fees, SUM(Tcharges.T_discount) Discount, Tcode.T_prov Provider FROM "C:\zz\Tcode.DAT" Tcode INNER JOIN "C:\zz\Tcharges.DAT" Tcharges ON Tcode.T_acctnum = Tcharges.T_acctnum AND Tcode.T_link = Tcharges.T_link WHERE (((Tcode.T_posted BETWEEN "01/01/2004" AND "01/31/2004") AND (Tcode.T_tcode < 30000))) GROUP BY Provider And that shows a list of amounts, for each provider, but I want to be able to show all the line items that added up to those totals. (I didnt include the group by provider issue in my question because that is nice but not necessary- I can always just do one provider at a time with a clause like "WHERE provider = 1") TIA Jerry