Having a little trouble getting this to work right.Users are grouped, then a count of total open and total closed.Open is StatusID IN (1, 2, 10)Closed is StatusID = 3Here is the starting point I have: SELECT u.FirstName + ' ' + u.LastName AS AssignedTo, COUNT(*) AS TotalClosed FROM Problems p LEFT OUTER JOIN Users u ON u.ID = p.AssignedToID WHERE p.statusid = 3 AND p.AssignedToID <> 0 GROUP BY u.FirstName, u.LastName SELECT u.FirstName + ' ' + u.LastName AS AssignedTo, COUNT(*) AS TotalOpen FROM Problems p LEFT OUTER JOIN Users u ON u.ID = p.AssignedToID WHERE p.statusid IN (1, 2, 10) AND p.AssignedToID <> 0 GROUP BY u.FirstName, u.LastName
How can the above two queries be combined into one query?I've been attempting a pivot but with no luck.Thanks!