Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT CASE WHEN COALESCE(e.FirstName,e.LastName) IS NOT NULL
- THEN CONCAT(e.FirstName,' ',e.LastName)
- ELSE
- 'None'
- END AS Employee,
- ISNULL(d.Name,'None') AS Department,
- ISNULL(c.Name,'None') AS Category,
- ISNULL(r.Description,'None'),
- ISNULL(CONVERT(VARCHAR, r.OpenDate, 104),'None') AS [OpenDate],
- ISNULL(s.Label,'None') AS STATUS,
- ISNULL(u.Name, 'None') AS [USER]
- FROM Reports r
- LEFT JOIN Employees e ON e.Id=r.EmployeeId
- LEFT JOIN Categories c ON c.Id=r.CategoryId
- LEFT JOIN Departments d ON d.Id=e.DepartmentId
- LEFT JOIN STATUS s ON s.Id=r.StatusId
- LEFT JOIN Users u ON u.Id=r.UserId
- ORDER BY e.FirstName DESC,e.LastName DESC,Department ASC,Category ASC,Description ASC,r.OpenDate ASC,
- STATUS ASC,[USER] ASC
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement