Mike:

This will do what you want (assuming your tables are named Summary and
Detail):

SELECT PatNumbr, RDate, RTime FROM Detail +
  GROUP BY PatNumber, RDate, RTime +
  HAVING SUM(Charge) <> +
     (SELECT TotalCharge FROM Summary WHERE +
          PatNumbr = Detail.PatNumbr AND +
          RDate = Detail.RDate AND +
          RTime = Detail.RTime)

However, if the only purpose for the Summary table is to summarize the
information in the Detail table, you can simply drop the Summary table and
issue this command:

CREATE VIEW Summary (PatNumbr, RDate, RTime, TotalCharge) +
  AS SELECT PatNumbr, RDate, RTime, SUM(Charge) +
        FROM Detail +
        GROUP BY PatNumbr, RDate, RTime

Now you will have the totals available with no space taken up in your data
files, no need to run the program that calculates the totals, and no
possibility of a mismatch between the tables.  All your previously existing
program code, forms and report that use the Summary table will work with the
new Summary view (except where you might have been editing or updating the
rows in Summary).
--
Larry


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com

Reply via email to