我有一个表JOB_DISPPLAY,如下:
JOB_STS JOB NAME FREQUENCY CHILD ID START END_DATE
R JOB001 Daily
E JOB001 CH001 01-01-2012 12-15-2016
R JOB001 CH002 06-12-2016 01-01-2049
F JOB002 Montly
E JOB002 CH003 06-12-2014 01-01-2016
E JOB002 CH004 03-10-2015 01-01-2016
R JOB003 Montly
F JOB003 CH006 06-12-2014 01-01-2018
F JOB003 CH007 03-10-2015 01-01-2018
这里JOB001是父母,它有2个孩子 - CH001和CH002。类似地,JOB002是父级并且具有2个子CH003和CH004。 Job STatus R =正在运行,F =已完成且E =已过期
现在我想更新父记录sts的表格,这样如果所有孩子在过去都有列end_date与今天相比,即如果子记录已过期(job_sts = E),那么父记录也应该过期。
因此我的最终结果应该是JOB002整套过期,如:
JOB_STS JOB NAME FREQUENCY CHILD ID START END_DATE
R JOB001 Daily
E JOB001 CH001 01-01-2012 12-15-2016
R JOB001 CH002 06-12-2016 01-01-2049
E JOB002 Montly
E CH003 06-12-2014 01-01-2016
E CH004 03-10-2015 01-01-2016
R JOB003 Montly
F CH006 06-12-2014 01-01-2018
F CH007 03-10-2015 01-01-2018
我怎样才能实现这个目标?
谢谢!