-- 문제7) EMPLOYEES 테이블에서 가장 많은 사원이 속해 있는 부서 번호와 사원수를 출력하라.
select department_id, count(*) from employees group by department_id order by count(*) desc limit 1;
가장 상단에 있는 row를 출력하고 싶을 때 사용가능!
'DB' 카테고리의 다른 글
[MySQL] 무결성 (0) | 2022.06.20 |
---|---|
[MySQL] create, drop, alter / insert, delete, select, update (0) | 2022.06.20 |
[MySQL] SUB Query (0) | 2022.06.17 |
[MySQL] Join (0) | 2022.06.17 |
[MYSQL] SELECT, WHERE, Group by, having (0) | 2022.06.16 |