1005 데이터베이스 문제풀기

- 전체 컬럼 조회

    select * from emp


- 직업이 MANAGER고 SALESMAN 사원들 이름, 직업, 급여 조회 단, 급여를 내림차순으로 정렬
    select ename, job, sal from emp where job ='manager' or job = 'salesman' order by sal desc

- 보너스를 받은 사원 이름, 보너스 조회 단, 0은 제외입니다.
    select ename, comm from emp where comm is not null and comm>0

- 사원이름에 A가 들어간 모든 사원 번호, 이름, 직업 조회
    select empno, ename, job from emp where ename like "%a%"

- 부서번호별 최대급여, 최소급여, 인원수 조회
    select max(sal), min(sal),count(empno) from emp group by deptno

- 직책별 평균급여 조회
    select job, avg(sal) from emp group by job order by avg(sal)

- 부서번호별 급여합계 조회 단, 10번 부서만
    select avg(sal) from emp where DEPTNO = 10 group by deptno

- 부서번호별 급여합계 조회 단, 급여합계가 5000 이상인 부서만
    select sum(sal) from emp group by deptno having sum(sal)>=5000

- 입사년도별 입사한 사원 수 조회
    select year(hiredate),count(empno) from emp group by year(hiredate) order by year(HIREDATE)

- 1983년 이후 입사한 사원의 보너스가 null 이면 급여의 10%를 보너스로 주고, 사원의 이름, 보너스, 급여 조회
    select ename, ifnull(comm,sal*0.1) , sal from emp where year(hiredate)>1983

- 아래 결과를 보고 쿼리를 작성
    select deptno as "부서별번호", max(sal) as "부서 번호별 급여 킹" from emp group by deptno

댓글

이 블로그의 인기 게시물

JAVA_Collection

JAVA_Collection2