I have a table that contains for each entry an incident_id, status (Let’s say either open or closed, date_raised (Date) and closure_date (Date).
I want to show a table that counts the number of incidents closed on a closure date (so the count of incident_id where status='closed' and closure_date is not null), and the number of incidents that remain open (count of incident_id where status='open' on that same day.
In case I’ve confused you, a table that looks like this:
______________________________________________________________________________
| closure date | count of incidents closed | count of incidents remaining open |
|--------------|---------------------------|-----------------------------------|
| 01-Sep-12 | 5 | 14 |
| ... | ... | ... |
I’ve managed a table that does the count of incidents closed like this:
SELECT COUNT(incident_id)
WHERE closure_date IS NOT NULL AND status="open"
GROUP BY closure_date
I’ve tried for hours now to get the other count working, but can’t so far 🙁
Edit: Here is an example of the table I have:
___________________________________________________
| incident_id | status | date_raised | closure_date |
|-------------|--------|-------------|--------------|
| 1 | closed | 01-Sep-12 | 01-Sep-12 |
| 2 | open | 30-Aug-12 | (null) |
| 3 | open | 02-Sep-12 | (null) |
| 4 | closed | 02-Sep-12 | 05-Sep-12 |
| ... | ... | ... | ... |
Would give the table:
______________________________________________________________________________
| closure date | count of incidents closed | count of incidents remaining open |
|--------------|---------------------------|-----------------------------------|
| 01-Sep-12 | 1 | 1 |
| 05-Sep-12 | 1 | 2 |
It seems to me that for each date, you want to get the number of issues that have been closed to date as well as the number of issues still open that were raised before that date, correct? So you might want something like this: