Question : MOVE THE LIKE WRKCNTER AND SHOPCDE TO ONE LINE

HELLO I WROTE A STATEMENT THAT WORKS GOOD BUT I WOULD LIKE TO HAVE THE WRKCTRCDE AND SHOPCDE THAT OR ALIKE ON THE SAME LINE. FOR EXAMPLE THE TWO "AUTO A" WHERE IT HAS THE COUNT FOR CIVILIANS THEN THE COUNT FOR CONTRACTOR ON SEPARATE LINES.
THANKS IN ADVANCED
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
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 LOGMAINT.dutyassignment
GROUP BY (employeetype, shopcde, wrkctrcde)
ORDER BY wrkctrcde, shopcde)
Attachments:
 
SCREENSHOT
 

Answer : MOVE THE LIKE WRKCNTER AND SHOPCDE TO ONE LINE

Try this below query:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
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))
Random Solutions  
 
programming4us programming4us