Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT E.Firstname+' '+E.Lastname AS FullName,
- ISNULL(CONVERT(varchar, CC.ReportSum), '0') + '/' +
- ISNULL(CONVERT(varchar, OC.ReportSum), '0') AS [Stats]
- FROM Employees AS E
- JOIN (SELECT EmployeeId, COUNT(1) AS ReportSum
- FROM Reports R
- WHERE YEAR(OpenDate) = 2016
- GROUP BY EmployeeId) AS OC ON OC.Employeeid = E.Id
- LEFT JOIN (SELECT EmployeeId, COUNT(1) AS ReportSum
- FROM Reports R
- WHERE YEAR(CloseDate) = 2016
- GROUP BY EmployeeId) AS CC ON CC.Employeeid = E.Id
- ORDER BY FullName
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement