Hi
I have this query that helps me to get the count of different stuff. My cases have system deadline and owner deadline. Owner deadlines are just a few days before system deadline. In cases when a case is past system deadline it is obviously also past owner deadline. However, I don’t want to count those overdues twice as it is doing now (one for system overdue and one for owner overdue) and only want to indicate a single system overdue.

Code:
SELECT Oshort,
Sum (CASE WHEN [System Deadline] - GETDATE() < 0  then 1 else 0 end) as [System past due],
Sum (CASE WHEN [Owner Deadline] - GETDATE() < 0 then 1 else 0 end) as [Owner past due],
Sum (CASE WHEN [Owner Deadline] - GETDATE() >=0 And [Owner Deadline] - GETDATE() < 7  then 1 else 0 end) as [Due Within 7 days],
Sum (CASE WHEN [Owner Deadline] - GETDATE() >=7 And [Owner Deadline] - GETDATE() < 14 then 1 else 0 end) as [Due Within 14 days],
Sum (CASE WHEN [Owner Deadline] - GETDATE() >=14  then 1 else 0 end) as [Due More Than 14 days]
FROM  DMS_Q_Activity 
Where 
Oshort in ('154','2556') 
Status = 'Closed'
Group by Oshort

How can I do that?

Thanks in advance.