题解 | #平均工资#
平均工资
http://www.nowcoder.com/practice/95078e5e1fba4438b85d9f11240bc591
有排序必有窗口函数
select avg(salary)
from
(select *,rank()over(order by salary) r from salaries where to_date='9999-01-01') a
where a.r!=1 #排除第一名
and a.r!=(select count(salary) from salaries where to_date='9999-01-01')
#排除最后一名,这里子查询算出总共有多少名的数量,正序的话名次=总数即为最后一名

查看21道真题和解析