Window function used in predicate

Item Value
SQLCODE -964
Constant SQLE_ILLEGAL_WINDOW_PREDICATE
SQLSTATE 42WA8
Sybase error code 13526
ODBC 2 State ERROR
ODBC 3 State ERROR

Probable cause 

A window function was used in the WHERE or HAVING clause of a SELECT statement. Consider making the SELECT into a derived table, putting the window function in the SELECT list of the derived table, and changing the predicate to reference the derived column.