Sparta/SQL-Practice

[MySQL][Practice] 돈을 벌기 위해 일을 합시다!

syuare 2025. 4. 3. 19:05

Table - sparta_employees

id name position salary hire_date
1 르탄이 개발자 30000 2022-05-01
2 배캠이 PM 40000 2021-09-25
3 구구이 파트장 35000 2023-06-01
4 이션이 팀장 50000 2021-07-09

더보기

1.sparta_employees 테이블에서 모든 직원의 이름(name)과 직급(position)을 선택하는 쿼리를 작성해주세요.

select name,position
from sparta_employees


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

select distinct position
from sparta_employees


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

select *
from sparta_employees
where salary between 40000 and 60000


4.sparta_employees  테이블에서 입사일(hire_date)이 2023년 1월 1일 이전인 모든 직원들을 선택하는 쿼리를 작성해주세요.

select *
from sparta_employees
where hire_date < '2023-01-01'