I have a table that contains for each entry incident_id , status (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 by closing date (so that the incident_id counter is where status='closed' and closure_date is not null ) and the number of incidents that remain open (number of incident_id where status='open' on the same day.
In case I confused you, the table looks like this:
______________________________________________________________________________ | closure date | count of incidents closed | count of incidents remaining open | |--------------|---------------------------|-----------------------------------| | 01-Sep-12 | 5 | 14 | | ... | ... | ... |
I dealt with a table in which the number of incidents is closed as follows:
SELECT COUNT(incident_id) WHERE closure_date IS NOT NULL AND status="open" GROUP BY closure_date
I tried for several hours to get another account to work, but I can’t: - (
Edit: Here is an example table that 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 | | ... | ... | ... | ... |
Gives a table:
______________________________________________________________________________ | closure date | count of incidents closed | count of incidents remaining open | |--------------|---------------------------|-----------------------------------| | 01-Sep-12 | 1 | 1 | | 05-Sep-12 | 1 | 2 |
source share