Auto commit
This commit is contained in:
parent
ba7a5971be
commit
be5497370f
@ -224,6 +224,26 @@ SELECT calculate_net_salary(3000);
|
||||
- 如果工资低于 60000 且工龄大于等于 3 年,返回 1(满足条件)。
|
||||
- 否则返回 0(不满足条件)。
|
||||
|
||||
```sql
|
||||
DELIMITER $$
|
||||
DROP FUNCTION IF EXISTS is_eligible_for_raise;
|
||||
CREATE FUNCTION is_eligible_for_raise(sal DECIMAL(10, 2), work_age INT)
|
||||
RETURNS INT
|
||||
DETERMINISTIC
|
||||
BEGIN
|
||||
IF sal < 60000 AND work_age >= 3 THEN
|
||||
RETURN 1;
|
||||
ELSE
|
||||
RETURN 0;
|
||||
END IF;
|
||||
END $$
|
||||
DELIMITER ;
|
||||
|
||||
SELECT is_eligible_for_raise(3000, 1);
|
||||
```
|
||||
|
||||
|
||||
|
||||
#### 练习题 7: 计算部门总工资
|
||||
|
||||
创建一个存储函数 `calculate_total_salary_by_dept`,接受部门 ID 作为参数,返回该部门所有员工的总工资。
|
||||
|
Loading…
x
Reference in New Issue
Block a user