Hi,
I need to get a plsql script to clean up a dataset that I have...
I have 2 tables, the first is the main dataset and the second a lookup table (location/region).
The first table has data that looks like:
TYPE EMP_ID CODE START_DT END_DT
1 177 DEP1 04-OCT-01 07-NOV-01
1 177 DEP1 08-NOV-01 15-FEB-02
1 177 DEP1 16-APR-02 08-MAY-02
1 177 DEP2 09-MAY-02 24-MAY-02
1 177 DEP2 05-JUN-02 12-JUN-02
2 178 DEP6 12-AUG-06 28-SEP-06
And the Second is basically:
CODE REGION
DEP1 LOCATION1
DEP2 LOCATION1
DEP3 LOCATION2
What I am looking to do is consolidate the dataset so that continuous periods within the same location are linked up and reduced to a single row.
EG. Results for above should look like:
TYPE EMP_ID CODE START_DT END_DT
1 177 DEP1 04-OCT-01 24-MAY-02
1 177 DEP2 05-JUN-02 12-JUN-02
2 178 DEP6 12-AUG-06 28-SEP-06
Variation on the type column for the Employee does not need to be considered, change in the code are only relevant when the location changes.
Thanks in advance. I think I should probably take a plsql course ;-)
I need to get a plsql script to clean up a dataset that I have...
I have 2 tables, the first is the main dataset and the second a lookup table (location/region).
The first table has data that looks like:
TYPE EMP_ID CODE START_DT END_DT
1 177 DEP1 04-OCT-01 07-NOV-01
1 177 DEP1 08-NOV-01 15-FEB-02
1 177 DEP1 16-APR-02 08-MAY-02
1 177 DEP2 09-MAY-02 24-MAY-02
1 177 DEP2 05-JUN-02 12-JUN-02
2 178 DEP6 12-AUG-06 28-SEP-06
And the Second is basically:
CODE REGION
DEP1 LOCATION1
DEP2 LOCATION1
DEP3 LOCATION2
What I am looking to do is consolidate the dataset so that continuous periods within the same location are linked up and reduced to a single row.
EG. Results for above should look like:
TYPE EMP_ID CODE START_DT END_DT
1 177 DEP1 04-OCT-01 24-MAY-02
1 177 DEP2 05-JUN-02 12-JUN-02
2 178 DEP6 12-AUG-06 28-SEP-06
Variation on the type column for the Employee does not need to be considered, change in the code are only relevant when the location changes.
Thanks in advance. I think I should probably take a plsql course ;-)