Applies To: 

ALM 11.5, SQL Database


Issue: 

Find the last logon date of a user.  This will be helpful when trying to archive old, or unused users. 


Solution:  

SELECT u.USER_NAME "Username", MAX(h.END_TIME) "Last Logon Date"
FROM td.SESSIONS_HISTORY h, td.USERS u
Where u.USER_NAME = h.USER_NAME AND NOT (u.USER_NAME = '_pc_system_' or u.USER_NAME = '_SYSTEM_USER_')
Group By u.USER_NAME

 

SELECT u.USER_NAME "Username", MAX(h.END_TIME) "Last Logon Date"

FROM td.SESSIONS_HISTORY h, td.USERS u

Where u.USER_NAME = h.USER_NAME AND NOT (u.USER_NAME = '_pc_system_' or u.USER_NAME = '_SYSTEM_USER_')

Group By u.USER_NAME