transform.Zeit_Sollzeit.sql 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. SET QUOTED_IDENTIFIER ON
  2. GO
  3. SET ANSI_NULLS ON
  4. GO
  5. CREATE VIEW [transform].[Zeit_Sollzeit] AS
  6. SELECT convert(varchar, [T1].[employee_number]) AS [Employee_ID_imr]
  7. , [T1]."employee_number" AS "Employee Number_Employees"
  8. , [T1]."name" AS "Name_Employees"
  9. , [T1]."initials" AS "Initials_Employees"
  10. , [T1]."mechanic_number" AS "Mechanic Number_Employees"
  11. , [T1]."salesman_number" AS "Salesman Number_Employees"
  12. , [T1]."employment_date" AS "Employment Date_Employees"
  13. , [T1]."termination_date" AS "Termination Date_Employees"
  14. , [T1]."leave_date" AS "Leave Date_Employees"
  15. , '1' AS "Hauptbetrieb_imr"
  16. , convert(varchar, [T1].[subsidiary]) AS "Standort_imr"
  17. , '1' AS "Hauptbetrieb"
  18. , convert(varchar, [T1].[subsidiary]) AS "Standort"
  19. , (rtrim(((([T1]."employee_number"))))) + ' - ' + [T1]."name" AS "Monteur"
  20. , 'Sollzeit' AS "Zeitkategorie"
  21. , '' AS "Zeitkategorie2"
  22. , [T2]."is_latest_record" AS "Is Latest Record"
  23. , [T2]."employee_number" AS "Employee Number"
  24. , [T2]."validity_date" AS "Validity Date"
  25. , [T2]."dayofweek" AS "Dayofweek"
  26. , [T2]."work_duration" AS "Work Duration"
  27. , [T2]."worktime_start" AS "Worktime Start"
  28. , [T2]."worktime_end" AS "Worktime End"
  29. , [T3].[Datum] AS "Datum"
  30. , [T3]."wochentage id" AS "Wochentage Id"
  31. , [T2]."work_duration" AS "Soll-Zeit"
  32. , [T3].[Datum] AS "Invoice Date"
  33. , [T4].[Hauptbetrieb_ID] AS "Hauptbetrieb_ID"
  34. , [T4].[Hauptbetrieb_Name] AS "Hauptbetrieb_Name"
  35. , [T4].[Standort_ID] AS "Standort_ID"
  36. , [T4].[Standort_Name] AS "Standort_Name"
  37. , [T5].[Zuordnung_Produktiv] AS "Monteur_Gruppe"
  38. , [T5].[Monteur_Ebene_1] AS "Monteur_Gruppe_2"
  39. , 'Sollzeit' AS "Activity_Codes_Group1"
  40. , '' AS "Activity_Codes_Group2"
  41. , 'Sollzeit' AS "Activity_Desc"
  42. FROM [LOCOSOFT]."dbo"."employees" [T1]
  43. INNER JOIN "LOCOSOFT"."dbo"."employees_worktimes" [T2] ON ([T1]."employee_number" = [T2]."employee_number")
  44. INNER JOIN "transform_imr"."current_date_Prognose" [T3] ON [T3].[Bundeslaender Id] = '10'
  45. LEFT JOIN [data].[GC_Department] [T4] ON convert(varchar, [T1].[subsidiary]) = [T4].[Standort] AND [T4].[Hauptbetrieb] = '1'
  46. LEFT JOIN [data].[GC_Mitarbeiter] [T5] ON convert(varchar, [T1].[employee_number]) = [T5].[Employee_ID]
  47. WHERE ([T3]."arbeitstag mofr" = 1)
  48. AND ([T2]."dayofweek" = [T3]."wochentage id")
  49. AND ([T3].[Datum] >= convert(datetime, '2023-05-01T00:00:00.000'))
  50. AND ([T2]."is_latest_record" = 1)
  51. GO
  52. SET QUOTED_IDENTIFIER OFF
  53. GO
  54. SET ANSI_NULLS OFF
  55. GO
  56. GO