I am working in Oracle SQL, suppose i have a table like this which has start date and completion date for stages of a project.
| Project No | STAGES | Start Date | completion date |
|---|---|---|---|
| PROJ_001 | 1 | 12-MAR-21 | 12-MAR-21 |
| PROJ_001 | 2 | 14-MAR-21 | 14-MAR-21 |
| PROJ_001 | 3 | 15-MAR-21 | 15-MAR-21 |
| PROJ_001 | 4 | 18-MAR-21 | 18-MAR-21 |
| PROJ_002 | 1 | 16-MAR-21 | 18-MAR-21 |
| PROJ_002 | 2 | 17-MAR-21 | 19-MAR-21 |
| PROJ_002 | 3 | 19-MAR-21 | 19-MAR-21 |
| PROJ_002 | 4 | 21-MAR-21 | 23-MAR-21 |
I need to bring the output as the below table. for stage level output, need to compare the completion date and start date and for project level, need to check the last stage of a project (i.e stage 4)
| Project No | STAGES | Start Date | completion date | Output 1 | output 2 project level |
|---|---|---|---|---|---|
| PROJ_001 | 1 | 12-MAR-21 | 12-MAR-21 | ON TIME | ON TIME |
| PROJ_001 | 2 | 14-MAR-21 | 14-MAR-21 | ON TIME | ON TIME |
| PROJ_001 | 3 | 15-MAR-21 | 15-MAR-21 | ON TIME | ON TIME |
| PROJ_001 | 4 | 18-MAR-21 | 18-MAR-21 | ON TIME | ON TIME |
| PROJ_002 | 1 | 16-MAR-21 | 18-MAR-21 | DELAYED | DELAYED |
| PROJ_002 | 2 | 17-MAR-21 | 19-MAR-21 | DELAYED | DELAYED |
| PROJ_002 | 3 | 19-MAR-21 | 19-MAR-21 | ON TIME | DELAYED |
| PROJ_002 | 4 | 21-MAR-21 | 23-MAR-21 | DELAYED | DELAYED |
can anyone help me?
Project Nocolumn really have nulls in many places?