题解 | SQLW21 统计员工薪资扣除比例
with t1 AS (
SELECT
a.staff_id,
b.staff_name,
ROUND(
100 * a.dock_salary / a.normal_salary
,1)
AS dock_ratio
FROM salary_tb a
LEFT JOIN staff_tb b
ON a.staff_id = b.staff_id
WHERE b.department = 'dep1'
ORDER BY dock_ratio DESC
)
SELECT staff_id,
staff_name,
CONCAT(dock_ratio,'%') AS dock_ratio
FROM t1;
# 这道题还是比较简单的

查看3道真题和解析