SELECT
NAME2 AS "부서",
NAME4 AS "이름",
NAME5 AS "직위",
(SELECT NAME1 FROM TEST.PERSON ZZ WHERE NAME5=XX.NAME4) AS "순서",
SUM_HH,
SUM_MM,
SUM_HH*60 AS SUM_HH_60,
SUM_MM AS SUM_MM_60,
SUM_HH*60 + SUM_MM AS SUM_FINAL,
(SUM_HH*60 + SUM_MM)/60 AS SUM_F_HH,
((SUM_HH*60 + SUM_MM)/60)/24 AS SUM_F_DAY
FROM
(
SELECT
NAME2, # "부서"
NAME4, # "이름"
NAME5, # "직위"
NAME25,
LPAD(NAME25,7,'00h '),
SUBSTR(LPAD(NAME25,7,'00h '),1,2),
SUBSTR(LPAD(NAME25,7,'00h '),5,2),
SUM(SUBSTR(LPAD(NAME25,7,'00h '),1,2)) AS SUM_HH,
SUM(SUBSTR(LPAD(NAME25,7,'00h '),5,2)) AS SUM_MM
FROM TEST.HYUNDAI_CHECK_PCOFF
WHERE 1=1
#AND SUBSTR(NAME6,1,10) > '2022-01-23'
AND NAME25 IS NOT NULL
GROUP BY NAME2,NAME4, NAME5
)XX
ORDER BY CAST(순서 AS SIGNED) ASC