John's Code Journey

[스파르타 사전캠프] SQL 걷기반 문제 1 본문

IT공부/SQL

[스파르타 사전캠프] SQL 걷기반 문제 1

Johnnnn 2025. 2. 4. 16:50
728x90

1) 돈을 벌기 위해 일을 합시다!

 
실제 데이터 베이스를 연결하기 전, SQL 문법을 탄탄하게 다져봅시다.
 
아래와 같은 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_empolyees;
 
2.
sparta_employees 테이블에서 중복 없이 모든 직급(position)을 선택하는 쿼리를 작성해주세요.
 
select distinct position from sparta_empolyees;
 
3.
sparta_employees 테이블에서 연봉(salary)이 40000과 60000 사이인 직원들을 선택하는 쿼리를 작성해주세요.
 
select salary
from sparta_empolyees
where salary between 40000 and 60000;
 
4.
sparta_employees 테이블에서 입사일(hire_date)이 2023년 1월 1일 이전인 모든 직원들을 선택하는 쿼리를 작성해주세요.

 

select hire_date

from sparta_empolyees

where hire_date < '2023-01-01';