SELECT IF(deptId = 1, '홍보', '기획') AS 부서명
,
GROUP_CONCAT(name
ORDER BY id DESC SEPARATOR ', ') AS 사원리스트
,
CONCAT(FORMAT(TRUNCATE(AVG(E.salary), 0), 0), '만원') AS 평균연봉
,
CONCAT(MAX(salary), '만원') AS 최고연봉
,
CONCAT(MIN(salary), '만원') AS 최소연봉
,
CONCAT(COUNT(*), '명') AS 사원수
FROM emp
GROUP BY deptId;