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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
| select hire_date, date_add(hire_date, interval 100 day) from employees;
select count(*) from employees;
select count(*) from employees where gender="M";
select count(*) from dept_emp where dept_no='d005' and to_date='9999-01-01';
select avg(salary) from salaries where to_date='9999-01-01';
-- 사원의 수를 성별로 구분하여 가져온다 select gender, count(*) from employees group by gender;
-- 각 부서에 근무하고 있는 사원의 수 select dept_no, count(*) from dept_emp where to_date='9999-01-01' group by dept_no;
-- 각 부서별 과거의 매니저의 수를 구한다 select dept_no, count(*) from dept_manager where not to_date='9999-01-01' group by dept_no;
-- 급여수령 시작일 별 급여 총합을 구한다 select from_date, sum(salary) from salaries group by from_date;
-- 10만명 이상이 사용하고 있는 직함의 이름과 직원의 수를 가져온다 select title, count(emp_no) from titles group by title having count(emp_no) >= 100000;
-- 5만명 이상이 근무하고 있는 부서의 부서 번호와 부서 소속 사원의 수를 가져온다 select dept_no, count(*) from dept_emp group by dept_no having count(*) >= 50000;
|