FALCONSEYE
Programmer
i have the following
I am trying to get how many active vs completed projects exist per estate_no. According to above data: I should have
one completed project on 7/27/2011 and one active project for estate_no C. two completed projects on 8/29/2011 and 6/27/2011 for estate_no B. one completed project on 7/29/2011 for estate_no A.
the problem i am having is that estate_no A has two dates for the same project_id with 4 different versions. They marked it ready but realized that it wasn't actually ready, did some more work and then marked it ready one more time.
any help will be appreciated.
ColdFusion Ninja for hire.
Code:
CREATE TABLE R_TEST
(
PROJECT_ID NUMBER,
VERSION NUMBER,
READY_DATE DATE,
ESTATE_NO VARCHAR2(1 BYTE)
)
TABLESPACE vvvvvvvvv
PCTUSED 0
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 64K
NEXT 1M
MINEXTENTS 1
MAXEXTENTS UNLIMITED
PCTINCREASE 0
BUFFER_POOL DEFAULT
)
LOGGING
NOCOMPRESS
NOCACHE
NOPARALLEL
MONITORING;
SET DEFINE OFF;
Insert into R_TEST
(PROJECT_ID, VERSION, READY_DATE, ESTATE_NO)
Values
(1345, 1, NULL, 'a');
Insert into R_TEST
(PROJECT_ID, VERSION, READY_DATE, ESTATE_NO)
Values
(1345, 2, NULL, 'a');
Insert into R_TEST
(PROJECT_ID, VERSION, READY_DATE, ESTATE_NO)
Values
(1345, 3, TO_DATE('07/01/2011 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 'a');
Insert into R_TEST
(PROJECT_ID, VERSION, READY_DATE, ESTATE_NO)
Values
(1345, 4, TO_DATE('07/29/2011 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 'a');
Insert into R_TEST
(PROJECT_ID, VERSION, READY_DATE, ESTATE_NO)
Values
(1059, 1, NULL, 'b');
Insert into R_TEST
(PROJECT_ID, VERSION, READY_DATE, ESTATE_NO)
Values
(1059, 2, TO_DATE('06/27/2011 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 'b');
Insert into R_TEST
(PROJECT_ID, VERSION, READY_DATE, ESTATE_NO)
Values
(2326, 1, NULL, 'b');
Insert into R_TEST
(PROJECT_ID, VERSION, READY_DATE, ESTATE_NO)
Values
(2326, 2, NULL, 'b');
Insert into R_TEST
(PROJECT_ID, VERSION, READY_DATE, ESTATE_NO)
Values
(2326, 3, TO_DATE('08/29/2011 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 'b');
Insert into R_TEST
(PROJECT_ID, VERSION, READY_DATE, ESTATE_NO)
Values
(998, 1, NULL, 'c');
Insert into R_TEST
(PROJECT_ID, VERSION, READY_DATE, ESTATE_NO)
Values
(998, 2, TO_DATE('07/27/2011 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 'c');
Insert into R_TEST
(PROJECT_ID, VERSION, READY_DATE, ESTATE_NO)
Values
(998, 1, NULL, 'c');
COMMIT;
I am trying to get how many active vs completed projects exist per estate_no. According to above data: I should have
one completed project on 7/27/2011 and one active project for estate_no C. two completed projects on 8/29/2011 and 6/27/2011 for estate_no B. one completed project on 7/29/2011 for estate_no A.
the problem i am having is that estate_no A has two dates for the same project_id with 4 different versions. They marked it ready but realized that it wasn't actually ready, did some more work and then marked it ready one more time.
any help will be appreciated.
ColdFusion Ninja for hire.