use fechell; CREATE TABLE transactions_summary_weekly (zipcode char(5) NOT NULL,contribution_year int(10) unsigned NOT NULL,contribution_week int(10) unsigned NOT NULL, total int(10) unsigned NOT NULL) engine 'MyISAM'; insert into transactions_summary_weekly(zipcode,contribution_year,contribution_week,total) (select zipcode,year(contribution_date),week(contribution_date),sum(contribution_amount) from transactions group by zipcode,year(contribution_date),week(contribution_date));