SELECT TO_CHAR(JB.出勤日期, 'YYYY-MM-DD') AS 日期,JB.MEMBER_NAME,JB.DEPARTMENT_NAME,JB.正式外包区分,JB.上班签到开始时间,JB.下班开始时间 FROM(SELECT E.出勤日期, E.MEMBER_NAME, E.DEPARTMENT_NAME, E.正式外包区分, MIN(CASE WHEN E.打卡目的 = '上班' THEN E.签到开始时间 ELSE NULL END) 上班签到开始时间, MAX(CASE WHEN E.打卡目的 = '下班' THEN E.签到开始时间 ELSE NULL END) 下班开始时间 FROM ( SELECT S.WORK_DATE / (1000 * 60 * 60 * 24)+ TO_DATE('1970-01-01 08:00:00', 'YYYY-MM-DD HH24:MI:SS') AS 出勤日期, S.SIGN_DATETIME / (1000 * 60 * 60 * 24)+ TO_DATE('1970-01-01 08:00:00', 'YYYY-MM-DD HH24:MI:SS') AS 签到开始时间, CASE WHEN S.SIGN_STATE = 1 THEN '正常' WHEN S.SIGN_STATE = 2 THEN '迟到' WHEN S.SIGN_STATE = 3 THEN '早退' WHEN S.SIGN_STATE = 4 THEN '矿工' WHEN S.SIGN_STATE = 5 THEN '请假' WHEN S.SIGN_STATE = 6 THEN '公出' WHEN S.SIGN_STATE = 7 THEN '加班免签' WHEN S.SIGN_STATE = 8 THEN '免签' WHEN S.SIGN_STATE = 9 THEN '无考勤' WHEN S.SIGN_STATE = 10 THEN '无效打卡' END AS 打卡状态, M.MEMBER_NAME, M.DEPARTMENT_NAME, CASE WHEN S.CREATE_TYPE = 1 THEN '排班' WHEN S.CREATE_TYPE = 2 THEN '请假' END AS 打卡原因, CASE WHEN S.ONOFF_STATE = 1 THEN '上班' WHEN S.ONOFF_STATE = 2 THEN '下班' END AS 打卡目的, CASE WHEN M.ACCOUNT_ID = '670869647114347' THEN '正式' ELSE '外包' END AS 正式外包区分 FROM V3XUSER.ATT_SIGN_DETAIL S LEFT JOIN V3XUSER.ATT_MEMBER M ON S.MEMBER_ID = M.MEMBER_ID WHERE ( M.DEPARTMENT_NAME = '来料检验' OR M.DEPARTMENT_NAME = '来料检查组' OR M.DEPARTMENT_NAME = '出货检验' OR M.DEPARTMENT_NAME = '过程检验' ) AND M.SCHEMEOVERTIME_SRC >0 AND S.SIGN_DATETIME IS NOT NULL)E WHERE E.出勤日期 >= TO_DATE('2022-07-01', 'YYYY-MM-DD') AND E.出勤日期 < TO_DATE('2022-08-01', 'YYYY-MM-DD')+ 1 GROUP BY E.出勤日期, E.MEMBER_NAME, E.DEPARTMENT_NAME, E.正式外包区分)JB UNION ALL SELECT TO_CHAR(开始,'YYYY-MM-DD')AS 日期,MEMBER_NAME,DEPARTMENT_NAME,OVERTIME_TYPE,正式外包区分,判断 FROM (SELECT tmp.开始, tmp.结束, tmp.减小时与不减, tmp.OT_MINUTE, tmp.OT_HOURS, tmp.MEMBER_NAME, tmp.DEPARTMENT_NAME, tmp.OVERTIME_TYPE, tmp.DEPARTMENT_ID, tmp.正式外包区分, CASE WHEN instr(tmp.减小时与不减, '.')= 0 AND tmp.减小时与不减*1>=1 THEN tmp.减小时与不减 WHEN tmp.减小时与不减*1>=0.499999 AND tmp.减小时与不减*1<1 THEN 0.5 WHEN tmp.减小时与不减*1>=0 AND tmp.减小时与不减*1<0.5 THEN 0 WHEN substr(tmp.减小时与不减, instr(tmp.减小时与不减, '.')+ 1, 1)* 1 >= 5 AND tmp.减小时与不减*1>=1 THEN substr(tmp.减小时与不减, 1, instr(tmp.减小时与不减, '.')-1)+ 0.5 WHEN substr(tmp.减小时与不减, instr(tmp.减小时与不减, '.')+ 1, 1)* 1 <5 AND tmp.减小时与不减*1>=1 then substr(tmp.减小时与不减, 1 , instr(tmp.减小时与不减, '.')-1)+ 0 END AS 判断 FROM ( SELECT t.开始, t.结束, round((t.结束-t.开始)* 24-1) AS 小时, t.OT_MINUTE, t.OT_HOURS, t.MEMBER_NAME, t.DEPARTMENT_NAME, t.OVERTIME_TYPE, t.DEPARTMENT_ID, t.正式外包区分, CASE WHEN to_char(t.开始, 'HH24')* 1 <= 11 AND to_char(t.结束, 'HH24')* 1 >= 13 THEN (t.结束-t.开始)* 24-1 ELSE (t.结束-t.开始)* 24 END AS 减小时与不减 FROM ( SELECT S.OT_START_DATETIME / (1000 * 60 * 60 * 24)+ TO_DATE('1970-01-01 08:00:00', 'YYYY-MM-DD HH24:MI:SS') AS 开始, S.OT_END_DATETIME / (1000 * 60 * 60 * 24)+ TO_DATE('1970-01-01 08:00:00', 'YYYY-MM-DD HH24:MI:SS') AS 结束, S.OVERTIME_TYPE, S.OT_MINUTE, S.OT_HOURS, M.MEMBER_NAME, M.DEPARTMENT_NAME, M.DEPARTMENT_ID, CASE WHEN M.DEPARTMENT_ID ='-2670959779560862801' THEN '外包' WHEN M.DEPARTMENT_ID ='-6677953676770980574' THEN '正式' WHEN M.DEPARTMENT_ID ='-6898710850797023410' THEN '正式' WHEN M.DEPARTMENT_ID ='5519322349391003696' THEN '外包' WHEN M.DEPARTMENT_ID ='-2175274102399940138' THEN '正式' END AS 正式外包区分 FROM V3XUSER.ATT_OVERTIME_DETAILS S LEFT JOIN V3XUSER.ATT_MEMBER M ON S.MEMBER_ID = M.MEMBER_ID WHERE M.SCHEMEOVERTIME_SRC >0 ) twHERE T.DEPARTMENT_NAME='来料检验' OR T.DEPARTMENT_NAME='来料检查组' OR T.DEPARTMENT_NAME='出货检验' OR T.DEPARTMENT_NAME='过程检验') tmpWHERE tmp.减小时与不减>0 AND tmp.开始 >= TO_DATE('2022-07-01','YYYY-MM-DD') AND tmp.结束 < TO_DATE('2022-08-01','YYYY-MM-DD')+1) ------我想要按日期和人和部门把这些后面的都合起来