I have a query that returns results like this:
All the total column is, is Open - Closed. in this example they are all null but there are numbers in Closed_Count down the table.
Is there a way to insert the missing date? (2010-09-11) in the table.
Like if i say date range 9-9 - 9-12. display 9-9 9-10 9-11 9-12 even if 9-10 is empty.
I'd want it to display like this:
Just for information... the original query is this:
- Matt
"If I must boast, I will boast of the things that show my weakness"
- Windows 2003 Server, 98 SE, XP
- VB.NET, VSTS 2010, ASP.NET, EXCEL VBA, ACCESS, SQL 2008
Date Opened_Count Closed_Count Total
2010-09-09 00:00:00.000 4 NULL 4
2010-09-10 00:00:00.000 2 NULL 2 2010-09-12 00:00:00.000 3 NULL 3
All the total column is, is Open - Closed. in this example they are all null but there are numbers in Closed_Count down the table.
Is there a way to insert the missing date? (2010-09-11) in the table.
Like if i say date range 9-9 - 9-12. display 9-9 9-10 9-11 9-12 even if 9-10 is empty.
I'd want it to display like this:
Date Opened_Count Closed_Count Total
2010-09-10 00:00:00.000 0 0 0
Just for information... the original query is this:
Code:
SELECT
isnull(cast([Opened_Date] as datetime), cast([Closed_Date] as datetime)) as 'Date',
[Opened_Count],
[Closed_Count],
isnull([Opened_Count],0)-isnull([Closed_Count],0) as Total
FROM
(SELECT convert(varchar,BG_DETECTION_DATE,101) as 'Opened_Date', COUNT(BG_DETECTION_DATE) as Opened_Count
FROM BUG
WHERE BG_DETECTED_IN_RCYC = 1118
AND BG_STATUS <> 'Invalid'
AND BG_STATUS <> 'New'
GROUP BY BG_DETECTION_DATE) AS OPENED
FULL OUTER JOIN
(SELECT Closed_Date, COUNT(Closed_Date) AS Closed_Count
FROM
(SELECT AU_ENTITY_ID ,convert(varchar,max(AU_TIME),101) AS Closed_Date
FROM BUG,AUDIT_LOG, AUDIT_PROPERTIES WITH (NOLOCK)
WHERE AU_ENTITY_TYPE = 'BUG'
AND AP_FIELD_NAME = 'BG_STATUS'
AND (BG_STATUS = 'Deferred' or BG_STATUS = 'Closed')
AND AU_ACTION_ID = AP_ACTION_ID
AND BG_BUG_ID = AU_ENTITY_ID
AND (AP_NEW_VALUE = 'Deferred' or AP_NEW_VALUE = 'Closed')
AND BG_DETECTED_IN_RCYC = 1118
GROUP BY AU_ENTITY_ID) AS AUDIT_CLOSED
GROUP BY AUDIT_CLOSED.CLOSED_DATE) AS CLOSED
ON OPENED.Opened_Date = CLOSED.Closed_Date
ORDER BY 'Date'
- Matt
"If I must boast, I will boast of the things that show my weakness"
- Windows 2003 Server, 98 SE, XP
- VB.NET, VSTS 2010, ASP.NET, EXCEL VBA, ACCESS, SQL 2008