我有一个包含开始日期和结束日期的员工名单。每次他们更换经理时,都会生成一个新行。我试图弄清楚他们全年每个月的部门是什么。
这是数据:
EMP_ID startdate enddate staffgroup
494694 2012-05-24 2013-01-09 Service
494694 2013-01-09 2013-02-03 Service
494694 2013-02-03 2013-02-04 Service
494694 2013-02-04 2013-02-05 Service
494694 2013-02-05 2013-02-07 Service
494694 2013-02-07 2013-02-15 Service
494694 2013-02-15 2013-03-20 Service
494694 2013-03-20 2013-06-01 Service
494694 2013-06-01 2013-06-03 Manager
494694 2013-06-03 2013-07-01 Manager
494694 2013-07-01 2099-12-31 Manager
预期成绩
EMP_ID Month staffgroup
494694 2013-01-01 Service
494694 2013-02-01 Service
494694 2013-03-01 Service
494694 2013-04-01 Service
494694 2013-05-01 Service
494694 2013-06-01 Manager
494694 2013-07-01 Manager