본문 바로가기
일일 문제 풀이/HackerRank

[SQL] 해커랭크 HackerRank 문제 풀이 Employee Salaries

by 엘리는 코딩 마스터 2025. 3. 10.

문제 Employee Salaries

Write a query that prints a list of employee names (i.e.: the name attribute) for employees in Employee having a salary greater than $2000 per month who have been employees for less than 10 months. Sort your result by ascending employee_id.

 

where employee_id is an employee's ID number, name is their name, months is the total number of months they've been working for the company, and salary is the their monthly salary.

 

주어진 Employee 테이블에서 다음 조건을 만족하는 직원들의 이름을 조회하는 SQL 쿼리를 작성해야 합니다.

  1. **급여(salary)**가 월 2,000달러 초과인 직원
  2. **근무 기간(months)**이 10개월 미만인 직원
  3. 결과를 employee_id(직원 ID) 기준 오름차순(ascending) 정렬

 

정답

select name
from employee
where salary > 2000 and months < 10
order by employee_id;

 

배운 점

greater than 이 초과

less than 이 미만