Hi Stefaans
I have a question, i am actually trying to do the same myself and i have a CTE table however i dont want to hold it i just want to preform the CTE and then an update, how would you adjust the engine for that? i'm on webfocus 8 and sql 2008 r2 if that does make a difference?
example of the code is:
ENGINE SQLMSS SET DEFAULT_CONNECTION CMH_STAGING
SQL SQLMSS
;WITH temp (employee_number, earned_hours, workdate) AS
(select t1.employee_number,sum(t1.EARNED_HOURS),MAX(workdate) from STG_MT_Pa t1
LEFT OUTER join STG_EMP_ATT_Man t2
on t1.Employee_Number = t2.EMPLOYEE_NUMBER
where t1.EARNING = '401' and WORKDATE >= t2.benchmark_Date
or EARNING = '116' and WORKDATE > = t2.benchmark_Date
or EARNING='400' and WORKDATE >= t2.benchmark_Date
or EARNING='505' and WORKDATE >=t2.benchmark_Date
or EARNING='515' and WORKDATE >=t2.benchmark_Date
group by t1.EMPLOYEE_NUMBER
)
update STG_EMP_ATT_Man set earned_hours =
(
select SUM(temp.earned_hours) from temp
where STG_EMP_ATT_Man.employee_number=temp.employee_number
group by temp.employee_number
)
END
WebFocus 8.02, SQL Server 2008r2