select T1."employee_number" as "Employee Number_Employees",
	   T1."name" as "Name_Employees",
	   T1."initials" as "Initials_Employees",
	   T1."mechanic_number" as "Mechanic Number_Employees",
	   T1."salesman_number" as "Salesman Number_Employees",
	   T1."employment_date" as "Employment Date_Employees",
	   T1."termination_date" as "Termination Date_Employees",
	   T1."leave_date" as "Leave Date_Employees",
	   T2."employee_number" as "Employee Number_Times",
	   T2."order_number" as "Order Number_Times",
	   T2."start_time" as "Start Time_Times",
	   T2."type" as "Type_Times",
	   T3."Order Number" as "Order Positions_Times",
	   T2."end_time" as "End Time_Times",
	   T2."exact_duration_seconds" / 60 as "Duration Minutes_Times",
	   T4."type" as "Type_Time_Types",
	   T4."description" as "Description_Time_Types",
	   T2."start_time" as "Datum",
	   '1' as "Hauptbetrieb",
	   '0' + (rtrim(((convert(varchar(50), T1."subsidiary"))))) as "Standort",
	   (rtrim(((convert(varchar(50), T1."employee_number"))))) + ' - ' + T1."name" as "Monteur",
	   CASE WHEN (T4."type" = 1) THEN ((T2."exact_duration_seconds" / 60) / 60) ELSE (0) END as "Anwesenheit",
	   CASE WHEN (T4."type" = 2) THEN ((T2."exact_duration_seconds" / 60) / 60) ELSE (0) END as "produktiv",
	   CASE WHEN (T4."type" = 1) THEN ((T2."exact_duration_seconds" / 60) / 60) ELSE (0) END as "unproduktiv",
	   CASE WHEN (T2."type" = 2) THEN ('produktiv') ELSE ('unproduktiv') END as "Zeitkategorie",
	   '' as "Zeitkategorie2",
	   (T2."exact_duration_seconds" / 60) / 60 as "Ges. Std.",
	   T2."order_number" as "Order Number",
	   (dayofweek(T2."start_time")) as "Wochentag_Datum",
	   T1."is_flextime" as "Is Flextime_Employees",
	   T1."break_time_registration" as "Break Time Registration_Employees"
from "dbo"."employees" T1,
	(("dbo"."times" T2 left outer join "dbo"."time_types" T4 on T2."type" = T4."type") left outer join "ims"."offene_Auftraege_Ums_ben_AW_fuer_Monteure" T3 on T3."order_number" = T2."order_number")
where (T1."employee_number" = T2."employee_number")
-- order by "Employee Number_Employees" asc,"Start Time_Times" asc,"Order Number_Times" asc