I was wondering if I can write this update statement without having to use a temp table.
In my query, the PA011101 contains the master list of job numbers, PA30101 has timesheets posted against those jobs and the JOBSTSATUS table is where I am trying to aggregate a total of all time per job. I was hoping there was a way to do this without using a temp table. The query below fails because invalid syntax with the WHERE. Is there anyway to restructure this query to perform the update without having to resort to the use of a temp table?
SET LABCOSTACT = (
SELECT SUM(case when PABase_Qty*PAUNITCOST IS NULL THEN 0 ELSE PABase_Qty*PAUNITCOST END)
FROM PA30101 pat
INNER JOIN (
select rtrim(pacontnumber) as pacontnumber
from PA01101) as proj
ON pat.paprojnumber = proj.pacontnumber
GROUP BY pat.paprojnumber
WHERE [MDGPWORK].[dbo].[JOBSTATUS].JOBNUMBER = pat.paprojnumber