Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Compute and Update in one statement

Author  Topic 

Trudye
Posting Yak Master

169 Posts

Posted - 2008-06-13 : 07:48:00
Hi Guys, got a problem.
I am trying to create a table of summarized fees. I was unable to do a Insert command so I settled for an Update command. But I ran into this error msg which I’m not sure how to fix. Can anyone see the problem or is it not even possible to Update and Compute in the same statement? Do I have to do a sub query?

Update FEE_SUMs_20080402
SET LOAN_Num = F.DDLOAN, Fee_Amt = F.DDMFEE
FROM FEE_Recs AS F
INNER JOIN dbo.Addr_20080402 ON
Account_Num = F.DDLOAN
ORDER BY F.DDLOAN
COMPUTE SUM(F.DDMFEE) BY F.DDLOAN

Msg 156, Level 15, State 1, Line 7
Incorrect syntax near the keyword 'ORDER'.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-06-13 : 07:51:04
Can you explain what you're trying to do with some sample data?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-06-13 : 07:53:59
is it this?

Update T
SET T.LOAN_Num = F.DDLOAN, T.Fee_Amt = F.TotalDDMFEE
FROM (SELECT DDLOAN,SUM(F.DDMFEE) AS TotalDDMFEE
FROM FEE_Recs
GROUP BY DDLOAN)AS F
INNER JOIN dbo.Addr_20080402 T
ON T.Account_Num = F.DDLOAN
Go to Top of Page

Trudye
Posting Yak Master

169 Posts

Posted - 2008-06-13 : 12:29:56
Thank you sooooo very much. You do good work, take a $100.00 out of Petty Cash and tell them I said it was ok. (lol)

That query worked GREAT I didn't have to change a thing.

Be well and have a great weekend,
Trudye
Go to Top of Page
   

- Advertisement -