题解 | #平均工资#

平均工资

https://www.nowcoder.com/practice/95078e5e1fba4438b85d9f11240bc591

select
#	s.emp_no #✖,没有group by的时候,select里也不能使用非聚合函数;where中不能用聚合函数
    avg(s.salary) as avg_salary
from
    salaries s
where
    s.to_date = '9999-01-01'
    and s.salary not in (
        select
            max(a.salary)
        from
            salaries a
        where
            a.to_date = '9999-01-01'
    )
    and s.salary not in (
        select
            min(b.salary)
        from
            salaries b
        where
            b.to_date = '9999-01-01'
    )

全部评论

相关推荐

点赞 评论 收藏
转发
点赞 收藏 评论
分享
牛客网
牛客企业服务