Hi
I've been scratching my head with why the following is giving me an error.
I've created a temporary table as follows:
CREATE TEMPORARY TABLE cashflow_sum_tmp (
CustName varchar(50), SiteName varchar (50),Period date ,ResSpend float, Sales float, MSpend float, Primary key (SiteName,Period));
I then insert data from a subquery which works fine but I then attempt to insert or update more data with following code:
insert into cashflow_sum_tmp (CustName, SiteName ,Period ,ResSpend, Sales , MSpend)
select
e.tblCustomer_Name, d.Site_Name, a.Period, 0, sum(a.HSales) as SalesH, 0
from sales_tmp a
join hilmark.tblsitesplotsjake c on a.Plot_ID = c.tblContractXIDJobNo join hilmark.tblsitesjake d on c.Site_ID = d.Site_ID join hilmark.tblCustomers_j e on d.Site_Company = e.tblCustomer_ID group by a.Period,d.Site_ID
on duplicate key update Sales = a.SalesH;
This compiles ok but when I run the report I get Unknown column 'a.SalesH' in 'field list'
I've tried on duplicate key update Sales = values(SalesH);
etc but with no success.
Can you help me please?
Thanks
Jake