b1nary0mega
6/10/2014 - 6:53 PM

Get a count of employee ids by unit, evaluation status, evaluation year, evaluation level and unit's dept for all persons who belong to a un

Get a count of employee ids by unit, evaluation status, evaluation year, evaluation level and unit's dept for all persons who belong to a unit that falls under the pediatric service id (10).

/* NAME: getPediatricEvals.sql
 * AUTH: James R. Aylesworth
 * DATE: 10-JUN-2014
 * DESC: Get a count of employee ids by unit, evaluation status, 
 *       evaluation year, evaluation level and unit's dept for all persons who 
 *       belong to a unit that falls under the pediatric service id (10).
*/
SELECT COUNT(E.EMPL_ID) as EMPL_COUNT,
  E.EVAL_STATUS,
  E.YEAR,
  E.EVAL_LEVEL,
  E.UNIT_ID,
  S.DEPT
FROM EVAL_EMPL_PR E
JOIN UNIT_SPEC S
ON E.UNIT_ID         = S.UNIT_ID
AND S.SERVICE_ID     = 10
WHERE E.EVAL_STATUS IN ('Finalized')
AND UPPER(E.EMPL_DS_STATUS) = 'Y'
AND E.UNIT_ID       IN
  ( SELECT DISTINCT s2.UNIT_ID FROM unit_spec s2 WHERE s2.SERVICE_ID = 10 )
AND E.YEAR NOT LIKE '%COMPDEV'
GROUP BY E.UNIT_ID,  E.EVAL_STATUS,  E.year,  E.eval_level,  S.DEPT
ORDER BY S.DEPT,  E.year,  E.EVAL_LEVEL,  E.UNIT_ID;