[oracle] 논리연산자

Jehyung Kim·2023년 1월 24일
0

Oracle SQL DB

목록 보기
5/18

and : 좌우 조건식이 모두 참일 경우 참

or : 좌우 조건식이 모두 거짓일 경우 거짓

not : 조건식의 결과를 부정

between and : 범위조건

in : 항목 조건

Q1) 10번 부서에서 근무하고 있는 직무가 MANAGER인 사원의 사원번호, 이름, 근무부서, 직무를 가져온다.

hint and

Q2) 입사년도가 1981년인 사원중에 급여가 1500 이상인 사원의 사원번호, 이름, 급여, 입사일을 가져온다.

hint between , and 둘다가능

Q3)20번 부서에 근무하고 있는 사원 중에 급여가 1500 이상인 사원의 사원번호, 이름, 부서번호, 급여를 가져온다.

Q4) 직속상관 사원 번호가 7698번인 사원중에 직무가 CLERK인 사원의 사원번호, 이름, 직속상관번호, 직무를 가져온다.

직송상관 번호 = mgr

Q5) 급여가 2000보다 크거나 1000보다 작은 사원의 사원번호, 이름, 급여를 가져온다.

hint or

Q6) 부서번호가 20이거나 30인 사원의 사원번호, 이름, 부서번호를 가져온다.

Q7) 직무가 CLERK, SALESMAN, ANALYST인 사원의 사원번호, 이름, 직무를 가져온다.

hint in 또는 or

Q8) 사원 번호가 7499, 7566, 7839가 아닌 사원들의 사원번호, 이름을 가져온다.

A1) select empno, ename, deptno, job
from emp
where deptno=10 and job='manager';
A2) select
from 
where hiredate **between** '1981/01/01' and hiredate <= '1981/12/31' and sal>=1500;
A3) select 사원번호, 이름, 부서번호, 급여
from 테이블
where sal >= 1500 and 부서=20
A4) select 사원번호, 이름 ,직속상관번호, 짐구
from 테이블
where mgr=7698 and job='clerk';
A5) select 
from
where sal>2000 or sal <1000;
A6) where 부서번호 = 20 or 부서번호 = 30
A7) where job in ('clerk', 'salesman', 'analyst');

where job = 'clerk' or job ='salesman' or job ='analyst';
A8) hint not 이나 <> 이나 not in

where not(empno=7499 or empno=7566 or empno=7839);

where not (empno in 7499, 7566, 7839);

where empno<>7499 and empno<>7566 and empno<>7839;
profile
tryandcatch

0개의 댓글