[DB] SQL 문제

*** scott계정 접속***

1. 1981년에 입사한 사람의 이름, 업무, 입사일자 조회

select ename, job, hiredate from emp where hiredate like '81%';


2. 사번이 7902, 7788, 7566인 사원의 이름, 업무, 급여, 입사일자 조회

select ename, job, sal, hiredate from emp where empno in('7902','7788','7566');


3. 업무가 manager,clerk, analyst가 아닌 직원의 이름, 업무, 급여, 부서번호 조회

select ename, job, sal, deptno from emp where job != 'MANAGER' and job != 'CLERK' and job != 'ANALYST';

select ename, job, sal, deptno from emp where job not in('MANAGER','CLERK','ANALYST');


4. 업무가 president 또는 salesman이고 급여가 1500인 직원의 이름, 급여, 업무, 부서번호 조회

select ename, sal, job, deptno from emp where sal=1500 and job in ('PRESIDEND','SALESMAN') ;


5. 가장 최근에 입사한 직원의 이름, 부서, 업무, 입사일자 조회

select ename, deptno, job, hiredate from emp where hiredate like '87%' order by hiredate desc;


6. 같은 부서내에서 같은 업무를 하는 직원의 급여가 많은 순으로 조회

selct deptno, job, sal from emp order by deptno, job, sal desc;


7. 커미션이 급여보다 10%이상 많은 직원의 급여가 많은순으로 조회

select ename, deptno, job, sal, comm from emp where sal*1.1<=comm;


8. 이름에 L자가 2개 있고 30번 부서이거나 직속상사가 7782인 직원의 이름, 부서, 직속상사 조회

select ename, deptno, mgr from emp where ename like '%LL%' and (deptno=30 or mgr=7782);


***hr계정 접속 ***

9. 부서번호가 100번인 직원의 이름, 부서, 급여 조회

select first_name, department_id, salary from employees where department_id=100;


10. 업무가 it programmer인 직원의 이름, 부서, 급여 조회

select first_name, department_id, salary from employees where job_id ='IT_PROG';


11. 이름이 luis인 직원의 이름과 성, 부서, 급여 조회

select first_name, last_name, department_id, salary where first_name='Luis';


12. 이름이 k로 시작되는 직원들의 이름, 부서, 급여 조회

select first_name, department_id, salary from employees where first_name like 'K%';


13. 부서번호가 50, 80번을 제외한 모든 사람의 이름, 부서, 급여를 조회

select first_name, department_id, salary from employees where department_id != 50 and department_id != 80;


14. 이름의 두번째 문자가 n인 사람의 이름, 부서, 급여 조회

select first_name, department_id, salary from employees where first_name like '_n%';

'DB' 카테고리의 다른 글

[DB] DML  (0) 2017.11.15
[DB] SQL문제2  (0) 2017.11.14
[DB] Function  (0) 2017.11.13
[DB] SQL - 확장 문법  (0) 2017.11.13
[DB] SQL - SELECT  (0) 2017.11.13

댓글

Designed by JB FACTORY