데이터 관련/SQL - 1일 1쿼리

2025.01.10(금) 1일 1쿼리

subindev 2025. 1. 10. 16:52

 

Quiz 1) 사원 번호가 110420인 직원의 이름, 직급, 역대 연봉 이력을 구하여라
SELECT 
    e.emp_no, 
    e.first_name, 
    e.last_name, 
	d.dept_name, 
    t.title, 
    sa.salary, 
    sa.from_date AS salary_from_date, 
    sa.to_date AS salary_to_date
FROM employees e
JOIN titles t ON e.emp_no = t.emp_no
JOIN dept_emp de ON e.emp_no = de.emp_no
JOIN departments d ON de.dept_no = d.dept_no
JOIN salaries sa ON e.emp_no = sa.emp_no
WHERE e.emp_no = 110420
ORDER BY 
    t.from_date, 
    de.from_date, 
    sa.from_date;