在MySQL中计算按比例分配的薪资存储过程

时间:2018-04-20 06:18:05

标签: mysql stored-procedures stored-functions

我的表薪水如下:

affective_date  salary
7/2/2017       $250.00 
3/25/2018      $300.00 
3/29/2018      $350.00 
4/20/2018      $400.00 

每月工资单样本从2014年3月23日开始到2017年4月22日,每月固定26天。

我手动计算了按比例分配的薪水:

period          23.03-24.03 25.03-28.03 29.03-19.04 20.04-22.04
number of day             2           3          19           2
salary              $250.00     $300.00     $350.00     $400.00 
earn/day (x/26)       $9.62      $11.54      $13.46      $15.38 
earn/hour (x/26/8)    $1.20       $1.44       $1.68       $1.92 
total earn           $19.23      $34.62     $255.77      $30.77 
total prorated salary                                   $340.38 

在这种情况下,一个月有超过1个工资,所以需要按工作日按比例分配。

我的问题是如何在MySQL中创建存储过程以获得按比例分配的薪水结果?

0 个答案:

没有答案
相关问题