deepgrewal22
Instructor
- May 2, 2005
- 108
I have a table with about 800,000 records and the records are organized as such:
PLANT_ID, PROJ_NUM, START_DATE, END_DATE
The problem that I am having is that some plants have more than one entry where the only difference is the dates. This is unnecessarily increasing the amount of records within this table.
*Unfortunately, the primary key is a combination of ALL of the fields. Therefore, no 2 records can be exactly the same at anytime.
WHAT IS THERE NOW:
------------------
PLANT1, 123456, 3/22/2007 6:00:00 AM, 5/11/2007 4:59:58 AM
PLANT1, 123456, 5/11/2007 4:59:59 AM, 1/2/2010 5:59:59 AM
WHAT IT SHOULD CONSOLIDATE TO:
------------------------------
PLANT1, 123456, 3/22/2007 6:00:00 AM, 1/2/2010 5:59:59 AM
*Note that the (earliest) start date from one record has been combined with the (latest) end date of the other record.
QUESTIONS:
----------
(1) Since the primary key is ALL of the fields, I cannot have two records that are exactly the same at any given time and need to delete one instance of a record. How can I perform the delete and complete the requirement outlined in the next question?
(2) How can I consolidate 2 different (records) sets of dates for a given PLANT_ID and PROJ_NUM into 1 (record) set of dates (keeping the earliest START_DATE, and latest END_DATE)?
Deep Grewal
Don't say the M word; you sound ignorant.
PLANT_ID, PROJ_NUM, START_DATE, END_DATE
The problem that I am having is that some plants have more than one entry where the only difference is the dates. This is unnecessarily increasing the amount of records within this table.
*Unfortunately, the primary key is a combination of ALL of the fields. Therefore, no 2 records can be exactly the same at anytime.
WHAT IS THERE NOW:
------------------
PLANT1, 123456, 3/22/2007 6:00:00 AM, 5/11/2007 4:59:58 AM
PLANT1, 123456, 5/11/2007 4:59:59 AM, 1/2/2010 5:59:59 AM
WHAT IT SHOULD CONSOLIDATE TO:
------------------------------
PLANT1, 123456, 3/22/2007 6:00:00 AM, 1/2/2010 5:59:59 AM
*Note that the (earliest) start date from one record has been combined with the (latest) end date of the other record.
QUESTIONS:
----------
(1) Since the primary key is ALL of the fields, I cannot have two records that are exactly the same at any given time and need to delete one instance of a record. How can I perform the delete and complete the requirement outlined in the next question?
(2) How can I consolidate 2 different (records) sets of dates for a given PLANT_ID and PROJ_NUM into 1 (record) set of dates (keeping the earliest START_DATE, and latest END_DATE)?
Deep Grewal
Don't say the M word; you sound ignorant.