Advertisement
Guest User

Untitled

a guest
Oct 6th, 2021
416
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 0.71 KB | None | 0 0
  1. SELECT CASE WHEN COALESCE(e.FirstName,e.LastName) IS NOT NULL
  2. THEN CONCAT(e.FirstName,' ',e.LastName)
  3. ELSE
  4. 'None'
  5. END AS Employee,
  6. ISNULL(d.Name,'None') AS Department,
  7. ISNULL(c.Name,'None') AS Category,
  8. ISNULL(r.Description,'None'),
  9. ISNULL(CONVERT(VARCHAR, r.OpenDate, 104),'None') AS [OpenDate],
  10. ISNULL(s.Label,'None') AS STATUS,
  11. ISNULL(u.Name, 'None') AS [USER]
  12. FROM Reports r
  13. LEFT JOIN Employees e ON e.Id=r.EmployeeId
  14. LEFT JOIN Categories c ON c.Id=r.CategoryId
  15. LEFT JOIN Departments d ON d.Id=e.DepartmentId
  16. LEFT JOIN STATUS s ON s.Id=r.StatusId
  17. LEFT JOIN Users u ON u.Id=r.UserId
  18. ORDER BY e.FirstName DESC,e.LastName DESC,Department  ASC,Category ASC,Description ASC,r.OpenDate ASC,
  19. STATUS ASC,[USER] ASC
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement