SELECT T1."employee_number" AS "Employee_ID",
	RSUM(T1."employee_number") AS "Summe  (Employee Number) Nr.1",
	T1."validity_date" AS "Validity Date",
	T1."is_latest_record" AS "Is Latest Record",
	T1."subsidiary" AS "Subsidiary",
	RSUM(T1."subsidiary") AS "Summe  (Subsidiary) Nr.1",
	T1."has_constant_salary" AS "Has Constant Salary",
	T1."name" AS "Name",
	T1."initials" AS "Initials",
	T1."customer_number" AS "Customer Number",
	RSUM(T1."customer_number") AS "Summe  (Customer Number) Nr.1",
	T1."mechanic_number" AS "Mechanic Number",
	RSUM(T1."mechanic_number") AS "Summe  (Mechanic Number) Nr.1",
	T1."salesman_number" AS "Salesman Number",
	RSUM(T1."salesman_number") AS "Summe  (Salesman Number) Nr.1",
	T1."is_business_executive" AS "Is Business Executive",
	T1."is_master_craftsman" AS "Is Master Craftsman",
	T1."employment_date" AS "Employment Date",
	T1."termination_date" AS "Termination Date",
	T1."leave_date" AS "leave_date",
	T1."is_flextime" AS "Is Flextime",
	RSUM(T1."is_flextime") AS "Summe  (Is Flextime) Nr.1",
	T1."break_time_registration" AS "Break Time Registration",
	T1."productivity_factor" AS "productivity_factor",
	RSUM(T1."productivity_factor") AS "Summe  (Productivity Factor) Nr.1",
	'1' AS "Client_DB",
	'' AS "Department",
	CASE 
		WHEN (T1."mechanic_number" IS NOT NULL)
			THEN ('Monteur')
		ELSE NULL
		END AS "Zuordnung_Funktion"
FROM "dbo"."employees" T1
WHERE (
		(T1."leave_date" >= convert(DATE, '2016-01-01'))
		OR (T1."leave_date" IS NULL)
		)
