× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Traditionally, an application like this, doesn't UPDATE into a summary
file. First the summary file is cleared and then INSERTed with the new
data. Like:

Now, before you start playing around with your INSERT, you should work out
your select. You said you wanted all the fields listed, no problem.
However, you wanted it GROUPed by transaction type. That could be a
problem. For example if you have multiple product types per paytype
you're going to have an issue.

One basic thing to remember is that all columns selected in a GROUP BY
have to:
A - Be in the GROUP BY statement, or,
B - Have some sort of summary function performed on them like: MAX, MIN,
SUM, etc

I am going to make a real broad assumption and assume that your sort is by
the order of the fields you have presented with a break for every PmtType.

First, see if this SELECT works.
select
PayDate,
Store,
Mfg,
PdType,
PmtType,
SUM(AmtPaid) as AmountPaid
From SalesDetail
Where PayDate = '2007/12/31'
Group by Store, Mfg, PdType, PmtType
Order by Store, Mfg, PdType, PmtType

If that works for you, and my assumption was not off, then it's a simple
matter to do

DELETE FROM SalesSum

INSERT INTO SalesSum (
select
PayDate,
Store,
Mfg,
PdType,
PmtType,
SUM(AmtPaid) as AmountPaid
From SalesDetail
Where PayDate = '2007/12/31'
Group by Store, Mfg, PdType, PmtType
Order by Store, Mfg, PdType, PmtType
)

Rob Berendt

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.