0

Below is the update query which I am using for which I am receiving "Incorrect syntax near the keyword 'group'" error message.

update PORTFOLIO set p.PF_F_FREE4 = sum(CASE    
WHEN c.FIXING_EXPR = 1  THEN
i.AMT_AFTER_XACT_DAT/(q.CUR_RATE)
ELSE
i.AMT_AFTER_XACT_DAT*(q.CUR_RATE) 
END)
from PORTFOLIO p, ID_POS_CASH i, CURRENCY c, ID_CUR_QUOTE q 
where p.PF_COD = i.PF_COD and   i.CUR_COD = c.CUR_COD 
and c.CUR_COD = q.CUR_COD and p.PF_C_FREE20 NOT IN ( 'NO ACI PARTICIPATION', NULL) 
and i.SETTLE_DAT = (select POS_MODIFIED_TO from ID_BAT_DAT) 
and (i.AMT_AFTER_XACT_DAT <> 0 or i.AMT_CURRENT<>0) 
group by i.CUR_COD having count(i.CUR_COD) >= 1

Can someone help me with the above?

Mike Gardner
  • 6,611
  • 5
  • 24
  • 34
harish g
  • 1
  • 1

1 Answers1

0

If I'm not mistaken, your problem is having both the GROUP BY and the HAVING clauses in an UPDATE statement.

I believe the answer is to use an inline Select statement or to use CTE to solve your problem.

Here is a link to a similar issue (and solution): Update with a Join, Group By, and Having

Community
  • 1
  • 1