-1

Iam updating an temporary table from the original table but it is having some issues can anyone help me for this problem here is my code and the error

The below given statement says Incorrect syntax near the keyword 'group'.

Update #tmpODU set Tn1Cnt=1,TnPay=isnull(sum(Amt),0)  
From Table1 
where Code COLLATE DATABASE_DEFAULT=TcCode 
COLLATE DATABASE_DEFAULT and Del='R' and Date<=dateadd(M,@n1D,@dDate) 
group by Code

can anyone help me...

thank you.....

Amit Bisht
  • 4,870
  • 14
  • 54
  • 83
ShaQue
  • 366
  • 3
  • 14

1 Answers1

0

i got the answer using below statment

and it is working as i expected

Update #tmpODU 
   set Tn1Cnt=1,
       Tn1Pay=isnull((select sum(Amt) 
                      From table1
                      where Code COLLATE DATABASE_DEFAULT=TcCode COLLATE DATABASE_DEFAULT 
                      and Del='R' 
                      and Date<=dateadd(M,@n1D,@dDate) group by Code),0)
ShaQue
  • 366
  • 3
  • 14