SQL Syntax Question update with no temp table

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?
UPDATE [MDGPWORK].[dbo].[JOBSTATUS]
		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

Open in new window

LVL 1
rwheeler23Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

musalmanERP ConsultantCommented:
I think you are missing the closing bracket before WHERE.

Any ways , Try below SQL to Update ,,, Must take backup of your table before update ...

--
UPDATE [MDGPWORK].[dbo].[JOBSTATUS]
SET LABCOSTACT = pat.TotalCost
FROM [MDGPWORK].[dbo].[JOBSTATUS] INNER JOIN
(
      SELECT pat.paprojnumber, SUM(case when PABase_Qty*PAUNITCOST IS NULL THEN 0 ELSE PABase_Qty*PAUNITCOST END) TotalCost
      FROM PA30101 pat INNER JOIN (
                              select rtrim(pacontnumber) as pacontnumber
                              from PA01101) as proj
                              ON pat.paprojnumber = proj.pacontnumber
                            )
            GROUP BY pat.paprojnumber

) pat
ON [MDGPWORK].[dbo].[JOBSTATUS].JOBNUMBER = pat.paprojnumber

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2005

From novice to tech pro — start learning today.