Question : matrix query

i am working on a matrix report for that i wrote the following query
in matrix report i will use xyz as columns and [mins to close] and totals as rows
my report works perfect. whenthere is a value for a group that groups appear in xyz column and that is used as headdig in matix report.
Now if some groups do not have values between the date range they dont appear in xyz. Now i want to make the groups static so that even if there is no value
still the group name has to show but if there is no value it has to show 0
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
SELECT      
                      (CASE WHEN [org].group= 'prod a1' THEN [org].sgroup WHEN [org].group= 'prod a2' THEN [org].sgroup
                       WHEN [org].group= 'prod a3' THEN [org].sgroup WHEN [org].group= 'prodource' THEN [org].sgroup
                       WHEN [org].group= 'legacy' THEN [org].sgroup WHEN [org].group= 'mapping' THEN [org].sgroup
                       ELSE [org].group END) AS xyz,
sum(DATEDIFF(n, Enq.OpenDate, Enq.ClosedDate))as [Mins to close],count(*) as totalenqs

FROM
Team RIGHT OUTER JOIN 
Org 
INNER JOIN 
Enq ON Org.Category = Enq.Category AND Org.Queue = Enq.OriginalQueue ON Team.[Rep ID] = Enq.ClosedBy 
where  Enq.closeddate >= @startdate  and  Enq.closeddate < @Enddate
and  (Enq.EnqType_ID = '123456') AND (Team.Team = 1) 

group by (CASE WHEN [org].group= 'prod a1' THEN [org].sgroup WHEN [org].group= 'prod a2' THEN [org].sgroup
                       WHEN [org].group= 'prod va3' THEN [org].sgroup WHEN [org].group= 'prodource' THEN [org].sgroup
                       WHEN [org].group= 'legacy' THEN [org].sgroup WHEN [org].group= 'mapping' THEN [org].sgroup
                       ELSE [org].groupEND)

Answer : matrix query

try this
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
SELECT      
          ISNULL((CASE WHEN [org].group= 'prod a1' THEN [org].sgroup WHEN [org].group= 'prod a2' THEN [org].sgroup
                       WHEN [org].group= 'prod a3' THEN [org].sgroup WHEN [org].group= 'prodource' THEN [org].sgroup
                       WHEN [org].group= 'legacy' THEN [org].sgroup WHEN [org].group= 'mapping' THEN [org].sgroup
                       ELSE [org].group END), 0) AS xyz,
sum(DATEDIFF(n, Enq.OpenDate, Enq.ClosedDate))as [Mins to close],count(*) as totalenqs

FROM
Team RIGHT OUTER JOIN 
Org 
INNER JOIN 
Enq ON Org.Category = Enq.Category AND Org.Queue = Enq.OriginalQueue ON Team.[Rep ID] = Enq.ClosedBy 
where  Enq.closeddate >= @startdate  and  Enq.closeddate < @Enddate
and  (Enq.EnqType_ID = '123456') AND (Team.Team = 1) 

group by (ISNULL(CASE WHEN [org].group= 'prod a1' THEN [org].sgroup WHEN [org].group= 'prod a2' THEN [org].sgroup
                       WHEN [org].group= 'prod va3' THEN [org].sgroup WHEN [org].group= 'prodource' THEN [org].sgroup
                       WHEN [org].group= 'legacy' THEN [org].sgroup WHEN [org].group= 'mapping' THEN [org].sgroup
                       ELSE [org].groupEND), 0))
Random Solutions  
 
programming4us programming4us