Thursday, July 30, 2015

SQL to get the Number of users connected to the environment in last 30 days

  SELECT TO_CHAR(A.LOGINDTTM,'YYYY-MM-DD'),count(distinct A.OPRID) "Users"
      FROM PSACCESSLOG A
     WHERE TO_CHAR(A.LOGINDTTM,'YYYY-MM-DD') >= TO_CHAR(SYSDATE - 30,'YYYY-MM-DD')
     GROUP BY TO_CHAR(A.LOGINDTTM,'YYYY-MM-DD')
     ORDER BY TO_CHAR(A.LOGINDTTM,'YYYY-MM-DD') DESC;

No comments:

Post a Comment