Advertisement
Guest User

Untitled

a guest
Jul 19th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.17 KB | None | 0 0
  1. GO
  2. CREATE TABLE [HeadCount_Ver01].[dbo].DepartmentSlotsLog(
  3. DepartmentID INTEGER NOT NULL,
  4. SlotID INTEGER NOT NULL,
  5. EmployeeID INTEGER NULL,
  6. ResourceManagerID INTEGER NULL,
  7. ServiceManagerID INTEGER NULL,
  8. LogDate DATETIME NOT NULL
  9.  
  10. PRIMARY KEY(DepartmentID, SlotID, LogDate)
  11. );
  12. GO
  13.  
  14. CREATE VIEW VResourceManagerLogData
  15.  
  16. AS
  17. SELECT
  18. D.DepartmentID AS DepartmentID,
  19. DSL.SlotID AS SlotID,
  20. D.DepartmentName AS DepartmentName,
  21. DSL.ResourceManagerID AS ResourceManagerID,
  22. E.LastName + ', ' + E.FirstName AS EmployeeFullName,
  23. E.EmployeeRole AS EmployeeRole,
  24. E.EmployeeLevel AS EmployeeRoleLevel,
  25. CONVERT(VARCHAR(50), DSL.LogDate, 107) AS RecordDate
  26.  
  27. FROM
  28.  
  29. Departments AS D
  30. LEFT JOIN DepartmentSlotsLog AS DSL
  31. ON D.DepartmentID = DSL.DepartmentID
  32.  
  33. LEFT JOIN Employees AS E
  34. ON DSL.ResourceManagerID = E.EmployeeID
  35.  
  36. CREATE VIEW VServiceManagerLogData
  37.  
  38. AS
  39. SELECT
  40. D.DepartmentID AS DepartmentID,
  41. DSL.SlotID AS SlotID,
  42. D.DepartmentName AS DepartmentName,
  43. DSL.ServiceManagerID AS ServiceManagerID,
  44. E.LastName + ', ' + E.FirstName AS EmployeeFullName,
  45. E.EmployeeRole AS EmployeeRole,
  46. E.EmployeeLevel AS EmployeeRoleLevel,
  47. CONVERT(VARCHAR(50), DSL.LogDate, 107) AS RecordDate
  48.  
  49.  
  50. FROM
  51.  
  52. Departments AS D
  53. LEFT JOIN DepartmentSlotsLog AS DSL
  54. ON D.DepartmentID = DSL.DepartmentID
  55.  
  56. LEFT JOIN Employees AS E
  57. ON DSL.ServiceManagerID = E.EmployeeID
  58.  
  59. CREATE VIEW VMasterLogData
  60.  
  61. AS
  62. SELECT
  63. VESLD.DepartmentID AS DepartmentID,
  64. VESLD.DepartmentName AS DepartmentName,
  65. VESLD.SlotID AS SlotID,
  66. VESLD.EmployeeID AS EmployeeID,
  67. VESLD.EmployeeFullName AS EmployeeFullName,
  68. VESLD.EmployeeRole AS EmployeeRole,
  69. VESLD.EmployeeRoleLevel AS EmployeeRoleLevel,
  70. VESLD.ResourceManagerID AS RMID,
  71. VRMLD.EmployeeFullName AS RMFullName,
  72. VESLD.ServiceManagerID AS SMID,
  73. VSMLD.EmployeeFullName AS SMFullName,
  74. VSMLD.RecordDate AS RecordDate
  75.  
  76. FROM
  77.  
  78. VEmployeeSlotsLogData AS VESLD
  79. LEFT JOIN VResourceManagerLogData AS VRMLD
  80. ON VESLD.ResourceManagerID = VRMLD.ResourceManagerID
  81. AND VESLD.SlotID = VRMLD.SlotID
  82.  
  83. LEFT JOIN VServiceManagerLogData AS VSMLD
  84. ON VESLD.ServiceManagerID = VSMLD.ServiceManagerID
  85. AND VESLD.SlotID = VSMLD.SlotID
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement