Illegal use of aggregate function in Update statement

Database
Enthusiast

Illegal use of aggregate function in Update statement

Hi,

I am getting thsi below error and would appreciate if someone guide me on how to fix it.

UPDATE LKP_TBL FROM

      [LKP_MAX_TEST_ID] LKP_TBL

     ,[st_TEST_LIVE_UF] STG

  SET TestId = MAX(STG.TestId)

--E--line 241-- SPL1027:E(L241), Missing/Invalid SQL statement'E(3872):Illegal use of an aggregate operation in an UPDATE statement.'.

  ;

2 REPLIES
Senior Apprentice

Re: Illegal use of aggregate function in Update statement

This is no Teradata syntax, seems to be SQL Server (and should also fail there).

UPDATE LKP_MAX_TEST_ID
SET TestId = (SELECT MAX(TestId) FROM st_TEST_LIVE_UF)
Enthusiast

Re: Illegal use of aggregate function in Update statement

Thanks Dieter. Its working now.