create_function.md 997 字节
Newer Older
M
Mars Liu 已提交
1 2 3 4 5
# 计税

每月生成工资单时,Joe 需要根据 employee 表的 salary 字段,计算出每个员工的所得税和税后工资,
因此他决定写一个 individual_income_tax 函数,根据睡前工资计算税额。不考虑实现逻辑,这个函数的声明应该是:

M
Mars Liu 已提交
6 7
点击进入[MySQL实战练习环境](https://mydev.csdn.net/product/pod/new?image=cimg-centos7-skilltreemysql&connect=auto&create=auto&utm_source=skill)

M
Mars Liu 已提交
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
## 答案

```mysql
create function individual_income_tax(salary decimal(12, 4)) returns decimal(12, 4)
deterministic
begin 
    -- ...
end;
```

## 选项

### A

```mysql
create store function individual_income_tax(salary decimal(12, 4)) returns decimal(12, 4)
    deterministic
begin 
    -- ...
end;
```

### B

```mysql
create function individual_income_tax(salary decimal(12, 4))
    deterministic
begin 
    -- ...
end;
```


### C

```mysql
create function decimal(12, 4) individual_income_tax(salary decimal(12, 4))
begin 
    -- ...
end;
```