hi Use
SELECT max (T1.[USER_CODE])UserCode, max (T1.[U_NAME])Name, (select max (a.[createDate]) from ausr a where T1.[USER_CODE] = a.[USER_CODE])CrateDate , max(T1.[lastLogin])LastLogin, T1.[Locked] FROM AUSR T0 INNER JOIN OUSR T1 ON T1.[USER_CODE] = T0.[USER_CODE] GROUP BY T1.[Locked] , T1.USER_CODE
Regards
Chetan