Mike Hughes
Registered User.
- Local time
- Today, 20:54
- Joined
- Mar 23, 2002
- Messages
- 493
Trying to write query, which will give me the “STAT_CASE_ID” for each case that had an “O” (open) CASE_STATUS between two dates. Some of the cases may have opened and closed during the two dates. All I want to know is what cases had a CASE_STATUS of “O” anytime during the two dates. Here is the query that I have, but this does not pick up all the cases that it should. I have also attached a sample DB. Any help would be appreciated.
SELECT DSERDBA_CASE_STATUS_CHANGE.STAT_CASE_ID
FROM DSERDBA_CASE_STATUS_CHANGE
WHERE (((DSERDBA_CASE_STATUS_CHANGE.STAT_FROM_CASE_STATUS)="O") AND ((DSERDBA_CASE_STATUS_CHANGE.STAT_BEGIN_DATE)<[BEGIN DATE]) AND ((DSERDBA_CASE_STATUS_CHANGE.STAT_END_DATE)>[END DATE] Or (DSERDBA_CASE_STATUS_CHANGE.STAT_END_DATE) Is Null)) OR (((DSERDBA_CASE_STATUS_CHANGE.STAT_BEGIN_DATE)>=[BEGIN DATE]) AND ((DSERDBA_CASE_STATUS_CHANGE.STAT_END_DATE)=[STAT_BEGIN_DATE]) AND ((DSERDBA_CASE_STATUS_CHANGE.STAT_TO_CASE_STATUS)="O"))
GROUP BY DSERDBA_CASE_STATUS_CHANGE.STAT_CASE_ID;
SELECT DSERDBA_CASE_STATUS_CHANGE.STAT_CASE_ID
FROM DSERDBA_CASE_STATUS_CHANGE
WHERE (((DSERDBA_CASE_STATUS_CHANGE.STAT_FROM_CASE_STATUS)="O") AND ((DSERDBA_CASE_STATUS_CHANGE.STAT_BEGIN_DATE)<[BEGIN DATE]) AND ((DSERDBA_CASE_STATUS_CHANGE.STAT_END_DATE)>[END DATE] Or (DSERDBA_CASE_STATUS_CHANGE.STAT_END_DATE) Is Null)) OR (((DSERDBA_CASE_STATUS_CHANGE.STAT_BEGIN_DATE)>=[BEGIN DATE]) AND ((DSERDBA_CASE_STATUS_CHANGE.STAT_END_DATE)=[STAT_BEGIN_DATE]) AND ((DSERDBA_CASE_STATUS_CHANGE.STAT_TO_CASE_STATUS)="O"))
GROUP BY DSERDBA_CASE_STATUS_CHANGE.STAT_CASE_ID;