题解 | #获取有奖金的员工相关信息。#

获取有奖金的员工相关信息。

https://www.nowcoder.com/practice/5cdbf1dcbe8d4c689020b6b2743820bf

SELECT emp_no,first_name,last_name,btype,salary,
    ROUND(
        CASE
            WHEN btype = 1 THEN salary * 0.1
            WHEN btype = 2 THEN salary * 0.2
            ELSE salary * 0.3
        END
    ,1) bonus
FROM employees
    JOIN emp_bonus USING(emp_no)
    JOIN salaries USING(emp_no)
WHERE to_date = '9999-01-01'

1、津贴计算

        CASE
            WHEN btype = 1 THEN salary * 0.1
            WHEN btype = 2 THEN salary * 0.2
            ELSE salary * 0.3
        END

2、当前薪水判定

WHERE to_date = '9999-01-01'

3、将相关信息输出

SELECT emp_no,first_name,last_name,btype,salary,
    ROUND(
        CASE
            WHEN btype = 1 THEN salary * 0.1
            WHEN btype = 2 THEN salary * 0.2
            ELSE salary * 0.3
        END
    ,1) bonus
FROM employees
    JOIN emp_bonus USING(emp_no)
    JOIN salaries USING(emp_no)
WHERE to_date = '9999-01-01'

全部评论

相关推荐

CrazyBucket:我今天下午也做梦在招聘会上面试一家小厂,给自己气笑了
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务