배운것
3. select distinct * column alias
1. from
2. where -> 조건절 특정행 제한
where department_id=90
4. order by
where절 쓸때 주의사항
**no row selected => 데이터가 없다. (코드가 잘못되었으니 확인)
단일비교 연산자
= 같음
보다 큼
= 크거나 같음
< 보다 작음
<= 작거나 같음
<> or != 같지않음
ex)연봉이 120000이상인 사원의 이름과 연봉을 출력하시오
SQL> select last_name, salary12
2 from employees
3 where salary12 >= 120000;
BETWEEN ...AND... - 두 값 사이(지정한 값 포함)
IN(set) - 값 목록 중의 값과 일치(복수연산자) 여러개의 같은값을동시에찾아냄
LIKE - 문자 패턴 일치(일부만 알고 있을때 ex) 's'한글자)
IS NULL - 널 값
1.between (사이,범위)
SQL> select last_name, salary
2 from employees
3 where salary between 2500 and 3500;
2.in (전체가 같을때 복수형)
SQL> select employee_id, last_name, salary, manager_id
2 from employees
3 where manager_id in (100,101,201);
3.like (S% 문장앞, %S문장끝에, %S% 문장전체)
(_o% => 맨앞글자를모르겠고 2번째는 o인 것을ed 찾아라)
SQL> select first_name
2 from employees =>성이 S로시작하는 사람
3 where first_name like 'S%';
4.is null (널값을 찾을때는 is null 밖에안됨 "= null"은 해석이안됨 ='null'은 문자형이라 숫자데이터와 다르기때문에 안나옴)
SQL> select last_name, manager_id
2 from employees
3 where manager_id is null;
where절의 조건문 조건추가연산자 AND(교집합), OR(둘중하나), NOT(조건아닌)조건문에서만쓰임
1 select last_name, salary
2 from employees
3 where department_id=90
4* and salary>=5000
같이썼을때 우선순위
1.and 2.or
열 정렬하는 절
-order by 절 (알리아스 사용가능)
order by hire_date DESC;(내림차순)
1 select last_name, department_id, salary
2 from employees
3* order by department_id, salary DESC
부서번호(오름차순)별로 급여를 (내림차순)
ASC 오름차순
DESC 내림차순