我有有數據,如基於數據
Employee_id | Name | M_date
------------+------+----------
1 | A | 5/1/2013
2 | B | 4/1/2014
3 | C | 7/1/2015
4 | D | 9/1/2015
5 | E | 10/1/2020
6 | X | 11/1/2019
我需要寫一個通過採取M_DATE
和sysdate
(今天返回僱員工作水平的甲骨文功能的Employee表如何寫甲骨文功能日期)。
的邏輯如下(僞代碼如下)
int nMonthDiff = (12 * (M_date year - Current year) + (M_date month - Current Month));
if (current year is greater than M_date year)
then employee_level = 'employee moved to other divison'
else if (nMonthDiff <= 12) THEN employee_level = 12
else if (nMonthDiff <= 24) THEN employee_level = 11
else if (nMonthDiff <= 36) THEN employee_level = 10
else if (nMonthDiff <= 48) THEN employee_level = 9
else if (nMonthDiff <= 60) THEN employee_level = 8
else employee_level = 'junior'
更換'NOW()'和'current_date'的Oracle(或'sysdate') –