1. 각 직책 별(job_title)로 급여의 총합을 구하되 직책이 Representative 인 사람은 제외하십시오. 단, 급여 총합이 30000 초과인 직책만 나타내며, 급여 총합에 대한 오름차순으로 정렬하십시오. 출력 결과의 컬럼명은 아래 결과와 동일하게 주십시오.
select j.job_title JOB, sum(e.salary) 급여
from jobs j,employees e
where j.job_id = e.job_id and
j.job_title not like '%Representative%'
group by j.job_title
having sum(e.salary)>30000
order by 급여;
2. 각 부서 이름 별로 2005년 이전에 입사한 직원들의 인원수를 조회하시오.
select d.department_name 부서명, count(e.employee_id) 인원수
from employees e, departments d
where e.department_id = d.department_id
and e.hire_date < '2005/1/1'
group by d.department_name;
3. 사원수가 3명 이상의 사원을 포함하고 있는 부서의 부서번호(department_id), 부서이름(department_name), 사원 수, 최고급여, 최저급여, 평균급여, 급여총액을 조회하여 출력하십시오. 출력 결과는 부서에 속한 사원의 수가 많은 순서로 출력하고, 컬럼명은 아래 결과와 동일하게 출력하십시오. (평균급여 계산시 소수점 이하는 버리시오)
select e.department_id 부서번호, d.department_name 부서명,
count(e.employee_id) 인원수, max(e.salary) 최고급여,min(e.salary) 최저급여
,floor(avg(e.salary)) 평균급여, sum(e.salary) 급여총액
from employees e,departments d
where e.department_id = d.department_id
group by e.department_id,d.department_name
having count(e.employee_id)>=3
order by 인원수 desc;
'Web Application,데이터베이스 활용 전문가 양성과정 > 오라클' 카테고리의 다른 글
[실습예제]- 단일행서브쿼리(hr) (0) | 2019.06.24 |
---|---|
[실습예제]서브쿼리 연습 (0) | 2019.06.24 |
[실습예제]조인연습 - hr계정 (0) | 2019.06.21 |
[실습예제]조인연습 (0) | 2019.06.21 |
[실습예제]group by (0) | 2019.06.21 |