select distinct WRKCTRCDE,SHOPCDE,
first_value(CIVILIAN) Over (partition by WRKCTRCDE,SHOPCDE order by CIVILIAN desc) CIVILIAN,
first_value(CONTRATOR) Over (partition by WRKCTRCDE,SHOPCDE order by CONTRATOR desc) CONTRATOR,
first_value(LOCAL_NAT) Over (partition by WRKCTRCDE,SHOPCDE order by LOCAL_NAT desc) LOCAL_NAT,
first_value(MILITARY) Over (partition by WRKCTRCDE,SHOPCDE order by MILITARY desc) MILITARY
from
(SELECT WRKCTRCDE,SHOPCDE,
CASE EMPLOYEETYPE
WHEN 'C' THEN CAST(TYPECOUNT AS VARCHAR2(40 BYTE))
ELSE '-'
END CIVILIAN,
CASE EMPLOYEETYPE
WHEN 'K' THEN CAST(TYPECOUNT AS VARCHAR2(40 BYTE))
ELSE '-'
END CONTRATOR,
CASE EMPLOYEETYPE
WHEN 'L' THEN CAST(TYPECOUNT AS VARCHAR2(40 BYTE))
ELSE '-'
END LOCAL_NAT,
CASE EMPLOYEETYPE
WHEN 'M' THEN CAST(TYPECOUNT AS VARCHAR2(40 BYTE))
ELSE '-'
END MILITARY
FROM
(SELECT
employeetype ,
wrkctrcde,
shopcde ,
COUNT(EMPLOYEETYPE)AS "TYPECOUNT"
FROM dutyassignment
GROUP BY (employeetype, shopcde, wrkctrcde)
ORDER BY wrkctrcde, shopcde))
|