deepgrewal22
Instructor
- May 2, 2005
- 108
I have a table with about 800,000 records and the records have attributes 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.
QUESTION:
----------
What would the query syntax be to only select those records whose project numbers (PROJ_NUM) appear twice for the same plant (PLANT_ID)?
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.
Code:
SELECT * FROM acct_to_proj;
PLANT_ID PROJ_NUM START_DATE END_DATE
---------- ---------- ------------- -------------
PLANT1 03423200 22-MAR-2007 11-MAY-2007
PLANT1 03423200 12-MAY-2007 02-JAN-2100
PLANT2 03423200 22-MAR-2007 11-MAY-2007
PLANT2 03423200 12-MAY-2007 02-JAN-2100
PLANT3 03423200 22-MAR-2007 02-JAN-2100
PLANT4 03423200 22-MAR-2007 11-MAY-2007
PLANT4 03423200 12-MAY-2007 02-JAN-2100
PLANT5 03423200 22-MAR-2007 02-JAN-2100
PLANT1 03423272 20-JUN-2000 31-OCT-2001
PLANT1 03423272 01-NOV-2001 15-AUG-2012
PLANT2 03423272 20-JUN-2000 31-OCT-2001
PLANT2 03423272 01-NOV-2001 15-AUG-2012
PLANT3 03423272 20-JUN-2000 31-OCT-2001
PLANT4 03423272 01-NOV-2001 15-AUG-2012
PLANT4 03423272 20-JUN-2000 31-OCT-2001
PLANT5 03423272 01-NOV-2001 15-AUG-2012
QUESTION:
----------
What would the query syntax be to only select those records whose project numbers (PROJ_NUM) appear twice for the same plant (PLANT_ID)?
Deep Grewal
Don't say the M word; you sound ignorant.