July 1, 2009 at 6:51 am
p
July 1, 2009 at 8:13 am
raghu (7/1/2009)
Update RequestsSet ER.[Part] = SUM(CAST(PT.[PREM] AS money)*Cred.CreditSigned / 100)
FROM Requests ER JOIN tblBuyinPtB Pt
ON ER.[SSN] = PT.[BOSSN] JOIN dbo.tblCredit Cred
ON Cred.
= Pt.
WHERE Pt.RIC is null OR Pt.RIC ='B'
GROUP BY Pt.BON
Please Help me writing this.......I am an error:getting incorrect syntax near group by
That would be because the update statement doesn't support a group by clause.
It looks like you would need to use a derived table here. Something like this:
update Requests
set ER.[Part] = t.Value
from Requests ER
INNER JOIN (select [BOSSN],
Value = SUM(CAST(PT.[PREM] AS money)*Cred.CreditSigned / 100)
from tblBuyinPtB Pt
JOIN dbo.tblCredit Cred ON Cred.
= Pt.
WHERE Pt.RIC is null OR Pt.RIC ='B'
GROUP BY Pt.[BOSSN]) t ON ER.[SSN] = t.[BOSSN]
Note that this code is untested... you did not supply table definitions or table data. If it doesn't work, please provide this information. See the link in my signature for how to do this.
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
July 1, 2009 at 8:54 am
Thank you very much .......This is working fine
July 1, 2009 at 3:27 pm
raghu,
May I ask why you felt it necessary to delete your initial post? The problem you were having may be useful to someone else; without your problem description they would never know it the answer would help them also.
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
July 2, 2009 at 10:05 pm
raghu (7/1/2009)
p
--Jeff Moden
Change is inevitable... Change for the better is not.
July 2, 2009 at 10:36 pm
WayneS (7/1/2009)
raghu,May I ask why you felt it necessary to delete your initial post? The problem you were having may be useful to someone else; without your problem description they would never know it the answer would help them also.
At least you had quoted the original post and he didn't completely change the problem on us like "someone else" on another thread did after I posted a solution to his code.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply