6.查找所有员工入职时候的薪水情况
查找所有员工入职时候的薪水情况
http://www.nowcoder.com/questionTerminal/23142e7a23e4480781a3b978b5e0f33a
法一:hire_data时间=from_data时间
select s.emp_no,s.salary from salaries s inner join employees e on s.emp_no=e.emp_no and s.from_date=e.hire_date order by s.emp_no desc
法二:找到工资表中最小的from_data
SELECT emp_no,salary FROM salaries GROUP BY emp_no HAVING min( from_date ) ORDER BY emp_no DESC
法三:找到工资表中最小的from_data
select a.emp_no,s.salary from salaries s, (select emp_no,min(from_date)as min_from_date from salaries group by emp_no)a where a.emp_no=s.emp_no and a.min_from_date=s.from_date order by a.emp_no desc
数据分析阿宇君的SQL题解 文章被收录于专栏
数据分析的SQL题目