transform.Zeit_Sollzeit.sql 2.1 KB

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