I have a simple table which includes two date fields;
Ticket
Creation
Resolved
And I'm trying to generate a count of Tickets created and resolved by day, week, month. However my abysmal tsql knowledge means I'm struggling to get the query to return the Ticket counts correctly. Here is my query in it's current format;
I can see the flaw in the logic, as it's grouping the ResolvedCount with the CreationDate but I'm struggling to find examples online of how to accomplish what I'm after.
I've just realised as I type this, a dreadful bodge would be to create two separate queries and then join them.
Any pointers, much appreciated.
Cheers, Paul.
Ticket
Creation
Resolved
And I'm trying to generate a count of Tickets created and resolved by day, week, month. However my abysmal tsql knowledge means I'm struggling to get the query to return the Ticket counts correctly. Here is my query in it's current format;
Code:
SELECT CreationDate, COUNT(TICKETS) AS Tickets, SUM(CASE WHEN ResolvedDate IS NULL THEN 0 ELSE 1 END) AS ResolvedCount
FROM table
GROUP BY CreationDate
ORDER BY CreationDate
I've just realised as I type this, a dreadful bodge would be to create two separate queries and then join them.
Any pointers, much appreciated.
Cheers, Paul.