Friday, November 25, 2011

SQLSTATE=42903

 I was in need to pass a max value in where condition. My folly, what i did is :

Incorrect : Select * from table_name where field = MAX(field);




Got below mentioned error in DB2

  42903(-120)[IBM][CLI Driver][DB2/SUN64] SQL0120N  Invalid use of an aggregate function or OLAP function.  SQLSTATE=42903
 (0.47 secs)

Correct :

Correct way is Inline Query

Select * from table_name where files = (Select MAX(filed) from table_name);