/*
List of Event Occurred
*/
SELECT e.ID
     , ec.EVENT_OCCURRENCE_ID
     , e.NAME
     , el.TIMESTAMP
     , DECODE(el.SEVERITY
            , 25, 'Crit'
            , 20 ,'Warn'
            , 18 ,'Error'
            , 15 ,'Clear'
            , 303 ,'NodeDown'
            , el.SEVERITY) Status
     , el.ENTRY       
FROM SMP_VDE_EVENT_OCCUR_DETAILS ecd
   , SMP_VDE_EVENT_OCCURRENCE ec
   , SMP_VDE_EVENT_LOG el
   , SMP_VDE_EVENT e 
WHERE e.ID = ec.EVENT_ID
  AND ec.EVENT_OCCURRENCE_ID = ecd.EVENT_OCCURRENCE_ID
  AND el.EVENT_OCCURRENCE_ID = ec.EVENT_OCCURRENCE_ID
  AND el.TIMESTAMP > SYSDATE - 60
  AND e.NAME NOT IN ( 'WHISTLER - OpenCursors#','SA017605 - SAVANT')
  AND LOWER(e.NAME) NOT LIKE ( '%weblogic%')
  AND LOWER(e.NAME) NOT LIKE '%alert log%'
  AND e.NAME = 'SA017603 - RUNQUEUE' 
--  AND n.ADMINISTRATOR_NAME LIKE '%%'
  AND ec.TARGET_NAME NOT IN ( 'tigris.eiffel.servista.com')
ORDER BY el.TIMESTAMP DESC

/*
Maximum and minimum time of Events on a day
*/
SELECT e.NAME
      , TRUNC(el.TIMESTAMP)
      , MAX((el.TIMESTAMP))
      , MIN((el.TIMESTAMP))
FROM SMP_VDE_EVENT_OCCUR_DETAILS ecd
   , SMP_VDE_EVENT_OCCURRENCE ec
   , SMP_VDE_EVENT_LOG el
   , SMP_VDE_EVENT e 
WHERE e.ID = ec.EVENT_ID
  AND ec.EVENT_OCCURRENCE_ID = ecd.EVENT_OCCURRENCE_ID
  AND el.EVENT_OCCURRENCE_ID = ec.EVENT_OCCURRENCE_ID
  AND el.TIMESTAMP > SYSDATE - 60
  AND e.NAME = 'SA017603 - RUNQUEUE' 
GROUP BY e.NAME,TRUNC(el.TIMESTAMP)  
ORDER BY TRUNC(el.TIMESTAMP) DESC
  
