sql 获取所有单位的员工档案数据
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sql 获取所有单位的员工档案数据相关的知识,希望对你有一定的参考价值。
SELECT EP.DEPT,
EP.UNIT_ID,
EP.EMPLOYEE_ID,
EP.UR_ID,
EP.FIRST_NAME,
EP.LAST_NAME,
EP.EMAIL,
EP.POS_CODE AS MSS_POS_CODE,
EP.TITLE,
EP.SMH_STRT_DT,
EP.POS_STRT_DATE,
EP.UNIT_STRT_DATE,
EP.MSS_UNIT_STRT_DT,
EP.MS_ALIAS,
EP.DAY_BREAK,
EP.GROUP_CHOICE_ID,
GP.GROUP_NAME AS UNIT_GROUP,
EP.SG_CHOICE_ID,
EP.CONFLICTS,
EP.REDSHIFTS,
EP.SCHOOL,
EP.MAXIMUM_DAY_SHIFT || '%' AS MAXIMUM_DAY_SHIFT,
EP.MIN_DAY_SHIFT || '%' AS MIN_DAY_SHIFT,
EP.MINIMUM_EVENING_SHIFT || '%' AS MINIMUM_EVENING_SHIFT,
EP.MINIMUM_NIGHT_SHIFT || '%' AS MINIMUM_NIGHT_SHIFT,
EP.MAX_WKLY_HRS || ' hrs' AS MAX_WKLY_HRS,
EP.MIN_WKLY_HRS || ' hrs' AS MIN_WKLY_HRS,
EP.MAX_TB_HRS || ' hrs' AS MAX_TB_HRS,
EP.MIN_TB_HRS || ' hrs' AS MIN_TB_HRS,
EP.MAX_HRS_PP || ' hrs' AS MAX_HRS_PP,
EP.MIN_HRS_PP || ' hrs' AS MIN_HRS_PP,
EP.CH_WK || ' hrs' AS CH_WK,
EP.CH_PP || ' hrs' AS CH_PP,
EP.CH_TB || ' hrs' AS CH_TB,
EP.CH_WE || ' hrs' AS CH_WE,
EP.SECURITY_LEVEL,
CASE
WHEN EP.EVAL_ID IS NOT NULL
THEN 'YES' || ' (' || EP.EVAL_ID || ')'
ELSE NULL
END AS AM_I_AN_EVALUATOR,
CASE
WHEN EP.EVAL_ME IS NOT NULL
THEN EM.Last_Name || ', ' || EM.First_Name || ' (' || EP.EVAL_ME || ')'
ELSE NULL
END AS EVALUATE_ME,
CASE
WHEN EP.SIGN_OFF_ME IS NOT NULL
THEN SM.Last_Name || ', ' || SM.First_Name || ' (' || EP.SIGN_OFF_ME || ')'
ELSE NULL
END AS SIGNS_EVAL,
EP.PH_CELL,
EP.PH_HOME,
EP.DATE_LAST_MODIFIED,
EP.DATE_CREATED,
CASE
WHEN LST.POS_CODE IS NOT NULL
AND LST.POS_CODE != EP.POS_CODE
THEN 'FAIL' || '(' || LST.POS_CODE || '/' || EP.POS_CODE || ')'
ELSE NULL
END AS HRMS_POS_CODE_CHECK,
CASE
WHEN LST.TITLE IS NOT NULL
AND LST.TITLE != EP.TITLE
THEN 'FAIL' || '(' || LST.TITLE || '/' || EP.TITLE || ')'
ELSE NULL
END AS HRMS_TITLE_CHECK,
CASE
WHEN LST.DAY_BREAK IS NOT NULL
AND LST.DAY_BREAK != EP.DAY_BREAK
THEN 'FAIL' || '(' || LST.DAY_BREAK || '/' || EP.DAY_BREAK || ')'
ELSE NULL
END AS HRMS_DAY_BREAK_CHECK
FROM EMPLOYEE_PROFILE EP
LEFT JOIN GROUPS GP
ON EP.Group_Choice_Id = Gp.Group_Id
AND EP.UNIT_ID = GP.Unit_ID
LEFT JOIN EVAL_ID_LOOKUP EM
ON EP.Eval_Me = EM.Eval_Id
LEFT JOIN EVAL_ID_LOOKUP SM
ON EP.Sign_Off_Me = SM.Eval_Id
LEFT JOIN GET_EMPL_LIST LST
ON EP.EMPLOYEE_ID = LST.EMPLOYEE_ID
AND EP.DEPT = LST.DEPT
WHERE EP.UNIT_ID = 'PACU_Peds'
AND EP.MSS_UNIT_TERM_DT IS NULL
ORDER BY EP.SECURITY_LEVEL DESC,
GP.GROUP_NAME ASC,
EP.LAST_NAME ASC;
以上是关于sql 获取所有单位的员工档案数据的主要内容,如果未能解决你的问题,请参考以下文章
牛客网SQL-第九题-获取所有非manager的员工emp_no
牛客网SQL-第九题-获取所有非manager的员工emp_no