indeed Sybase has window functions however i believe my version is older and still does not support window functions (i get Incorrect syntax near keyword 'OVER')
Forgot to mention that my database is sybase and as far as i know i can't do row number within the query using partition. I meant putting the Rownumber()...