November 28th, 2000, 09:05 AM
I'd like to keep one table with all the raw data, and one smaller, summarized table. Whenever the raw table is appended to or modified, I want to run code that will summarize the raw table based on a unique key and keep the summarized data in the smaller table.
So is there an sql command to combine the select statemenet, with a GROUP BY command and to copy the results to a summarized table?
November 28th, 2000, 11:17 AM
You could use two queries to accomplish that.
Run this first to empty the target table:
DELETE FROM small_table
Then run this to insert summarized data from big_table into small_table:
INSERT INTO small_table (field1, field2, field3, field4) SELECT sum(field1), sum(field2), sum(field3), sum(field4) FROM big_table WHERE some_condition GROUP BY field1, field2 ORDER BY field 3
[This message has been edited by NoXcuz (edited November 28, 2000).]