Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Summary of Records in Second Table

Status
Not open for further replies.

BattleDroid42

Programmer
May 17, 2002
100
US
How would I create a trigger to summarize the records in one table to a second?

For example, let's say I have an empty table (TABLE1) and I insert 10 records for 3 different people for different dollar amounts. I would like the trigger to append the totals for the 3 people in TABLE2. Then, the next time I append say 5 more records I would like it to take the added 5 records and append a summary of those records to TABLE2 as well without having to resummarize ALL the records. I want the tables to stay in sync during deletes as well.

How?

Thanks!
 
hi,

You dont have to resummarize the totals everytime rows are added/deleted.
Create a trigger on table A- on insert/delete where in you can add/substract the new values to the already existing total in Table B.

 
The records in both tables are by date so it isn't a matter up updating a grand total, it's a matter of summarizing the records added to the first table and INSERTing the summary to the second.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top