1、题目描述:
输入描述:
无
输出描述:
dept_no | emp_no | salary |
---|---|---|
d001 | 10001 | 88958 |
d002 | 10006 | 43311 |
d003 | 10005 | 94692 |
d004 | 10004 | 74057 |
d005 | 10007 | 88070 |
d006 | 10009 | 95409 |
2、代码:主要考察group by和筛选条件的理解,若分组之前用的条件用 where 过滤,分组之后用的条件用 having 连接,例如求所有的工资和大于一百万的部门。
select d.dept_no,d.emp_no,max(s.salary) as salary from salaries s join dept_emp d on d.emp_no=s.emp_no where s.to_date=‘9999-01-01‘ and d.to_date=‘9999-01-01‘ group by d.dept_no ;
原文:https://www.cnblogs.com/guoyu1/p/12242221.html