pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jerry Blumenthal <jerblum4@comcast.net>
To: pgsql-sql@postgresql.org
Subject: Aggregate versus lineitem report
Date: Fri, 21 Oct 2005 11:32:13 -0400
Message-ID: <435909FD.5040904@comcast.net> (raw)

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



view thread (2+ messages)  latest in thread

Message-ID: <435909FD.5040904@comcast.net>
Permalink:  ../435909FD.5040904@comcast.net/
Also on:    postgresql.org/message-id/435909FD.5040904@comcast.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: jerblum4@comcast.net
  Subject: Re: Aggregate versus lineitem report
  In-Reply-To: <435909FD.5040904@comcast.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox