我有两个表 PROCESS 和 STEP 以及里面的一些数据,如下所示。(他们有 1-N 的关系。)
PROCESS ->
ID START_TIME STARTED_BY STATUS
1 31/08/2012 User1 FINISHED
2 31/08/2012 User2 FINISHED
3 05/09/2012 User3 ACTIVE
STEP ->
ID PROCESS_ID START_TIME END_TIME STATUS
1 1 31/08/2012 02/09/2012 FINISHED
2 1 02/09/2012 03/09/2012 FINISHED
3 1 03/09/2012 10/09/2012 FINISHED
4 2 31/08/2012 04/09/2012 FINISHED
5 2 04/09/2012 06/09/2012 FINISHED
6 2 06/09/2012 09/09/2012 FINISHED
7 3 05/09/2012 06/09/2012 FINISHED
8 3 06/09/2012 NULL ACTIVE
我需要的是一个 JOIN,它将为我提供已完成流程的开始和结束时间,如下所示:
PROCESS_ID START_TIME END_TIME
1 31/08/2012 10/09/2012
2 31/08/2012 09/09/2012
我需要写什么样的 JOIN 语句来完成这个?