All Forums Database
ASOORI15 5 posts Joined 02/13
20 Feb 2015
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.'.
  ;

dnoeth 4628 posts Joined 11/04
20 Feb 2015

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)

 

Dieter

ASOORI15 5 posts Joined 02/13
20 Feb 2015

Thanks Dieter. Its working now.

You must sign in to leave a comment.