오늘 배운 문구는 where 과 distinct 입니다.

먼저 문제들을 풀어보겠습니다.

image.png

문제 1)sparta_employees 테이블에서 연봉(salary)이 40000과 60000 사이인 직원들을 선택하는 쿼리를 작성해주세요.

select * 
from sparta_employees
where salary between 40000 and 6000;

문제 2) sparta_employees 테이블에서 중복 없이 모든 직급(position)을 선택하는 쿼리를 작성해주세요.

select distinct position
from sparta_employees;

조건문 - where

where는 특정한 조건을 필터링 해야 할 때 사용됩니다.

위처럼 한 가지의 조건 뿐만 아니라 여러가지 조건도 걸 수 있습니다.

select * 
from sparta_employees
where salary between 20000 and 40000
			and position = '개발자';

중복제거 - Distinct