SELECT (
		CASE 
			WHEN (((ucase(T1."Make"))) IS NULL)
				THEN ('00')
			ELSE (((ucase(T1."Make"))))
			END
		) + '-' + (
		CASE 
			WHEN (
					(((rtrim(T2."ACCT_NR"))) LIKE '2%')
					AND (T3."SITE" IS NULL)
					)
				THEN ('01')
			ELSE ((right('00' + (left(T3."SITE", 2)), 2)))
			END
		) + '-' + ((rtrim(T2."ACCT_NR"))) + '-' + (
		CASE 
			WHEN (
					(T3."DEPARTMENT" IS NULL)
					OR ((rtrim(T3."DEPARTMENT")) = '')
					)
				THEN ('00')
			ELSE ((rtrim(T3."DEPARTMENT")))
			END
		) + '-' + (
		CASE 
			WHEN (T3."DESTINATION" = 'FZ')
				THEN ('11')
			WHEN (
					(T3."DESTINATION" = '00')
					AND (
						(
							CASE 
								WHEN ((T3."PRICE_CODE") = '#')
									THEN ('99')
								ELSE (T3."PRICE_CODE")
								END
							) <> ''
						)
					)
				THEN (
						(
							CASE 
								WHEN ((T3."PRICE_CODE") = '#')
									THEN ('99')
								ELSE (T3."PRICE_CODE")
								END
							)
						)
			WHEN (
					(
						(T3."DESTINATION" = '00')
						AND (
							(
								CASE 
									WHEN ((T3."PRICE_CODE") = '#')
										THEN ('99')
									ELSE (T3."PRICE_CODE")
									END
								) = ''
							)
						)
					AND (T4."CUSTOMER_GROUP" <> '')
					)
				THEN (T4."CUSTOMER_GROUP")
			WHEN ((rtrim(T3."DESTINATION")) = '')
				THEN ('00')
			ELSE (T3."DESTINATION")
			END
		) + '-' + (
		upper((
				(
					rtrim(CASE 
							WHEN (
									(T5."MODEL_LINE" IS NOT NULL)
									AND (T5."MODEL_LINE" <> '')
									)
								THEN (T5."MODEL_LINE")
							WHEN (
									(T3."MODEL_LINE" IS NOT NULL)
									AND (T3."MODEL_LINE" <> '')
									)
								THEN (T3."MODEL_LINE")
							WHEN (
									(T3."PRODUCT_GROUP" IS NOT NULL)
									AND (T3."PRODUCT_GROUP" <> '')
									)
								THEN (T3."PRODUCT_GROUP")
							WHEN (
									(T3."REPAIR_GROUP" IS NOT NULL)
									AND (T3."REPAIR_GROUP" <> '')
									)
								THEN (T3."REPAIR_GROUP")
							ELSE ('00')
							END)
					)
				))
		) AS "Acct Nr",
	T2."LEDGER_ACCTS_NAME" AS "Ledger Accts Name",
	T2."LEDGER_ACCTS_NAME2" AS "Ledger Accts Name2",
	T2."HANDLER" AS "Handler_2",
	T2."DEPT_SPLIT" AS "Dept Split",
	T2."TYPE_ACCTT" AS "Type Acctt",
	T3."ACCT_NO" AS "Acct No",
	T3."BOOKKEEP_DATE" AS "Bookkeep Date",
	T3."BOOKKEEP_PERIOD" AS "Bookkeep Period",
	T3."DOCUMENT_NO" AS "Document No",
	T3."ORIGIN" AS "Origin",
	T3."STATUS" AS "Status",
	T3."DEBIT_AMOUNT" AS "Debit Amount",
	T3."CREDIT_AMOUNT" AS "Credit Amount",
	T3."DEBIT_QUANTITY" AS "Debit Quantity",
	T3."CREDIT_QUANTITY" AS "Credit Quantity",
	T3."AA_TRTYPE" AS "Aa Trtype",
	T3."DEPARTMENT" AS "Department",
	T3."STOCK" AS "Stock",
	T3."MAKE_FAMILY" AS "Make Family",
	T3."MAKE" AS "Make",
	T3."VEHICLE_TYPE" AS "Vehicle Type",
	T3."MODEL_LINE" AS "Model Line",
	T3."FACTORY_MODEL" AS "Factory Model",
	T3."WORKSHOP_MODEL" AS "Workshop Model",
	T3."PRODUCT_GROUP" AS "Product Group",
	T3."REPAIR_GROUP" AS "Repair Group",
	T3."KIT_GROUP" AS "Kit Group",
	T3."TIME_CODE" AS "Time Code",
	T3."INT_VOUCHER_NO" AS "Int Voucher No",
	T3."BALANCING_MARK" AS "Balancing Mark",
	T3."USED_VEH_DEST_CODE" AS "Used Veh Dest Code",
	T3."USE_OF_VEHICLE" AS "Use Of Vehicle",
	T3."ACCT_NO_NEXT_CHART" AS "Acct No Next Chart",
	T6."REFERENCE_IDENT" AS "Reference Ident",
	T6."TRANSACT_DATE" AS "Transact Date",
	T6."HANDLER" AS "Handler",
	T6."PROGRAM" AS "Program",
	T6."FUNCTION_CODE" AS "Function Code",
	T6."MODUL" AS "Modul",
	T6."DOCUMENT_KEY" AS "Document Key",
	T6."COMMENT" AS "Comment",
	T7."DEPARTMENT_TYPE_ID" AS "Department Type Id",
	T7."DESCRIPTION" AS "Description_2",
	T7."DEPARTMENT_GROUP" AS "Department Group",
	T8."AA_TRTYPE_ID" AS "Aa Trtype Id",
	T8."DESCRIPTION" AS "Description",
	T8."OWN_DESCRIPTION" AS "Own Description",
	'1' AS "Rechtseinheit",
	CASE 
		WHEN (
				(
					(
						(
							CASE 
								WHEN (((ucase(T1."Make"))) IS NULL)
									THEN ('00')
								ELSE (((ucase(T1."Make"))))
								END
							) + '-' + (
							CASE 
								WHEN (
										(((rtrim(T2."ACCT_NR"))) LIKE '2%')
										AND (T3."SITE" IS NULL)
										)
									THEN ('01')
								ELSE ((right('00' + (left(T3."SITE", 2)), 2)))
								END
							) + '-' + ((rtrim(T2."ACCT_NR"))) + '-' + (
							CASE 
								WHEN (
										(T3."DEPARTMENT" IS NULL)
										OR ((rtrim(T3."DEPARTMENT")) = '')
										)
									THEN ('00')
								ELSE ((rtrim(T3."DEPARTMENT")))
								END
							) + '-' + (
							CASE 
								WHEN (T3."DESTINATION" = 'FZ')
									THEN ('11')
								WHEN (
										(T3."DESTINATION" = '00')
										AND (
											(
												CASE 
													WHEN ((T3."PRICE_CODE") = '#')
														THEN ('99')
													ELSE (T3."PRICE_CODE")
													END
												) <> ''
											)
										)
									THEN (
											(
												CASE 
													WHEN ((T3."PRICE_CODE") = '#')
														THEN ('99')
													ELSE (T3."PRICE_CODE")
													END
												)
											)
								WHEN (
										(
											(T3."DESTINATION" = '00')
											AND (
												(
													CASE 
														WHEN ((T3."PRICE_CODE") = '#')
															THEN ('99')
														ELSE (T3."PRICE_CODE")
														END
													) = ''
												)
											)
										AND (T4."CUSTOMER_GROUP" <> '')
										)
									THEN (T4."CUSTOMER_GROUP")
								WHEN ((rtrim(T3."DESTINATION")) = '')
									THEN ('00')
								ELSE (T3."DESTINATION")
								END
							) + '-' + (
							upper((
									(
										rtrim(CASE 
												WHEN (
														(T5."MODEL_LINE" IS NOT NULL)
														AND (T5."MODEL_LINE" <> '')
														)
													THEN (T5."MODEL_LINE")
												WHEN (
														(T3."MODEL_LINE" IS NOT NULL)
														AND (T3."MODEL_LINE" <> '')
														)
													THEN (T3."MODEL_LINE")
												WHEN (
														(T3."PRODUCT_GROUP" IS NOT NULL)
														AND (T3."PRODUCT_GROUP" <> '')
														)
													THEN (T3."PRODUCT_GROUP")
												WHEN (
														(T3."REPAIR_GROUP" IS NOT NULL)
														AND (T3."REPAIR_GROUP" <> '')
														)
													THEN (T3."REPAIR_GROUP")
												ELSE ('00')
												END)
										)
									))
							)
						) LIKE '2%'
					)
				AND (T3."SITE" IS NULL)
				)
			THEN ('01')
		ELSE ((left(T3."SITE", 2)))
		END AS "Betrieb",
	CASE 
		WHEN (((ucase(T1."Make"))) IS NULL)
			THEN ('00')
		ELSE (((ucase(T1."Make"))))
		END AS "Marke",
	T3."DEBIT_AMOUNT" + T3."CREDIT_AMOUNT" AS "Betrag",
	'1' AS "Mandant",
	(T3."DEBIT_QUANTITY" + T3."CREDIT_QUANTITY") AS "Menge",
	CASE 
		WHEN ((- 1 * datediff(day, (getdate()), T3."BOOKKEEP_DATE")) <= 360)
			THEN ((left((((T3."DOCUMENT_NO"))), 7)) + ' - ' + T6."COMMENT")
		ELSE NULL
		END AS "Text",
	(left(T3."ACCT_NO", 1)) AS "Susa_2",
	T9."ORDER_NUMBER" AS "Order Number",
	T9."LINE_NUMBER" AS "Line Number",
	T9."INV_TIME" AS "Inv Time",
	T9."INV_TIME_INT" AS "Inv Time Int",
	T9."MAKE_TIME_UNIT" AS "Make Time Unit",
	T3."SITE" AS "Site",
	CASE 
		WHEN (T3."DEPARTMENT" = '    ')
			THEN ('00')
		ELSE (T3."DEPARTMENT")
		END AS "KST",
	T5."MODEL_LINE" AS "Model Line_vpp5q",
	T5."MOD_LIN_SPECIFY" AS "Mod Lin Specify_vpp5q",
	CASE 
		WHEN (T5."MODEL_LINE" IS NOT NULL)
			THEN (T5."MODEL_LINE" + ' - ' + T5."MOD_LIN_SPECIFY")
		WHEN (T3."MODEL_LINE" IS NOT NULL)
			THEN (T3."MODEL_LINE")
		WHEN (T3."PRODUCT_GROUP" IS NOT NULL)
			THEN (T3."PRODUCT_GROUP")
		WHEN (T3."REPAIR_GROUP" IS NOT NULL)
			THEN (T3."REPAIR_GROUP")
		ELSE ('00 - ohne')
		END AS "Kostentr�ger_mit_Bez_",
	(
		substring((
				CASE 
					WHEN (T5."MODEL_LINE" IS NOT NULL)
						THEN (T5."MODEL_LINE" + ' - ' + T5."MOD_LIN_SPECIFY")
					WHEN (T3."MODEL_LINE" IS NOT NULL)
						THEN (T3."MODEL_LINE")
					WHEN (T3."PRODUCT_GROUP" IS NOT NULL)
						THEN (T3."PRODUCT_GROUP")
					WHEN (T3."REPAIR_GROUP" IS NOT NULL)
						THEN (T3."REPAIR_GROUP")
					ELSE ('00 - ohne')
					END
				), 1, 2)
		) AS "Kostentr�ger",
	T10."CUSTOMER_NUMBER" AS "Customer Number",
	T4."CUSTOMER_GROUP" AS "Customer Group",
	CASE 
		WHEN (T3."DESTINATION" = 'FZ')
			THEN ('11')
		WHEN (
				(T3."DESTINATION" = '00')
				AND (
					(
						CASE 
							WHEN ((T3."PRICE_CODE") = '#')
								THEN ('99')
							ELSE (T3."PRICE_CODE")
							END
						) <> ''
					)
				)
			THEN (
					(
						CASE 
							WHEN ((T3."PRICE_CODE") = '#')
								THEN ('99')
							ELSE (T3."PRICE_CODE")
							END
						)
					)
		WHEN (
				(
					(T3."DESTINATION" = '00')
					AND (
						(
							CASE 
								WHEN ((T3."PRICE_CODE") = '#')
									THEN ('99')
								ELSE (T3."PRICE_CODE")
								END
							) = ''
						)
					)
				AND (T4."CUSTOMER_GROUP" <> '')
				)
			THEN (T4."CUSTOMER_GROUP")
		WHEN ((rtrim(T3."DESTINATION")) = '')
			THEN ('00')
		ELSE (T3."DESTINATION")
		END AS "Absatzkanal",
	T2."TYPE_ACCTT" AS "GuV_Bilanz",
	(left(T3."ACCT_NO", 1)) AS "Susa",
	CASE 
		WHEN (
				(
					(
						substring((
								CASE 
									WHEN (T3."DEPARTMENT" = '    ')
										THEN ('00')
									ELSE (T3."DEPARTMENT")
									END
								), 1, 1)
						) = '1'
					)
				AND (
					NOT (
						(
							substring((
									CASE 
										WHEN (T5."MODEL_LINE" IS NOT NULL)
											THEN (T5."MODEL_LINE" + ' - ' + T5."MOD_LIN_SPECIFY")
										WHEN (T3."MODEL_LINE" IS NOT NULL)
											THEN (T3."MODEL_LINE")
										WHEN (T3."PRODUCT_GROUP" IS NOT NULL)
											THEN (T3."PRODUCT_GROUP")
										WHEN (T3."REPAIR_GROUP" IS NOT NULL)
											THEN (T3."REPAIR_GROUP")
										ELSE ('00 - ohne')
										END
									), 1, 2)
							)
						) IN ('00')
					)
				)
			THEN ('Neuwagen')
		WHEN (
				(
					(
						substring((
								CASE 
									WHEN (T3."DEPARTMENT" = '    ')
										THEN ('00')
									ELSE (T3."DEPARTMENT")
									END
								), 1, 1)
						) = '2'
					)
				AND (
					NOT (
						(
							substring((
									CASE 
										WHEN (T5."MODEL_LINE" IS NOT NULL)
											THEN (T5."MODEL_LINE" + ' - ' + T5."MOD_LIN_SPECIFY")
										WHEN (T3."MODEL_LINE" IS NOT NULL)
											THEN (T3."MODEL_LINE")
										WHEN (T3."PRODUCT_GROUP" IS NOT NULL)
											THEN (T3."PRODUCT_GROUP")
										WHEN (T3."REPAIR_GROUP" IS NOT NULL)
											THEN (T3."REPAIR_GROUP")
										ELSE ('00 - ohne')
										END
									), 1, 2)
							)
						) IN ('00')
					)
				)
			THEN ('Gebrauchtwagen')
		WHEN (
				(
					(
						substring((
								CASE 
									WHEN (T3."DEPARTMENT" = '    ')
										THEN ('00')
									ELSE (T3."DEPARTMENT")
									END
								), 1, 1)
						) = '3'
					)
				AND (
					NOT (
						(
							substring((
									CASE 
										WHEN (T5."MODEL_LINE" IS NOT NULL)
											THEN (T5."MODEL_LINE" + ' - ' + T5."MOD_LIN_SPECIFY")
										WHEN (T3."MODEL_LINE" IS NOT NULL)
											THEN (T3."MODEL_LINE")
										WHEN (T3."PRODUCT_GROUP" IS NOT NULL)
											THEN (T3."PRODUCT_GROUP")
										WHEN (T3."REPAIR_GROUP" IS NOT NULL)
											THEN (T3."REPAIR_GROUP")
										ELSE ('00 - ohne')
										END
									), 1, 2)
							)
						) IN ('00')
					)
				)
			THEN ('Teile & Zubeh�r')
		WHEN (
				(
					(
						substring((
								CASE 
									WHEN (T3."DEPARTMENT" = '    ')
										THEN ('00')
									ELSE (T3."DEPARTMENT")
									END
								), 1, 1)
						) = '4'
					)
				AND (
					NOT (
						(
							substring((
									CASE 
										WHEN (T5."MODEL_LINE" IS NOT NULL)
											THEN (T5."MODEL_LINE" + ' - ' + T5."MOD_LIN_SPECIFY")
										WHEN (T3."MODEL_LINE" IS NOT NULL)
											THEN (T3."MODEL_LINE")
										WHEN (T3."PRODUCT_GROUP" IS NOT NULL)
											THEN (T3."PRODUCT_GROUP")
										WHEN (T3."REPAIR_GROUP" IS NOT NULL)
											THEN (T3."REPAIR_GROUP")
										ELSE ('00 - ohne')
										END
									), 1, 2)
							)
						) IN ('00')
					)
				)
			THEN ('Service')
		ELSE ('Ohne Kostentr�ger')
		END AS "Ebene31",
	CASE 
		WHEN (
				(
					CASE 
						WHEN (((ucase(T1."Make"))) IS NULL)
							THEN ('00')
						ELSE (((ucase(T1."Make"))))
						END
					) IN ('OP')
				)
			THEN ('OP')
		WHEN (
				(
					CASE 
						WHEN (((ucase(T1."Make"))) IS NULL)
							THEN ('00')
						ELSE (((ucase(T1."Make"))))
						END
					) IN ('VW')
				)
			THEN ('VW')
		ELSE NULL
		END AS "Marke f�r Kostentr�ger",
	CASE 
		WHEN (
				(
					CASE 
						WHEN (((ucase(T1."Make"))) IS NULL)
							THEN ('00')
						ELSE (((ucase(T1."Make"))))
						END
					) IN ('OP')
				)
			THEN (
					(
						CASE 
							WHEN (
									(
										CASE 
											WHEN (((ucase(T1."Make"))) IS NULL)
												THEN ('00')
											ELSE (((ucase(T1."Make"))))
											END
										) IN ('OP')
									)
								THEN ('OP')
							WHEN (
									(
										CASE 
											WHEN (((ucase(T1."Make"))) IS NULL)
												THEN ('00')
											ELSE (((ucase(T1."Make"))))
											END
										) IN ('VW')
									)
								THEN ('VW')
							ELSE NULL
							END
						) + (
						CASE 
							WHEN (T5."MODEL_LINE" IS NOT NULL)
								THEN (T5."MODEL_LINE" + ' - ' + T5."MOD_LIN_SPECIFY")
							WHEN (T3."MODEL_LINE" IS NOT NULL)
								THEN (T3."MODEL_LINE")
							WHEN (T3."PRODUCT_GROUP" IS NOT NULL)
								THEN (T3."PRODUCT_GROUP")
							WHEN (T3."REPAIR_GROUP" IS NOT NULL)
								THEN (T3."REPAIR_GROUP")
							ELSE ('00 - ohne')
							END
						)
					)
		WHEN (
				(
					CASE 
						WHEN (((ucase(T1."Make"))) IS NULL)
							THEN ('00')
						ELSE (((ucase(T1."Make"))))
						END
					) IN ('VW')
				)
			THEN (
					(
						CASE 
							WHEN (
									(
										CASE 
											WHEN (((ucase(T1."Make"))) IS NULL)
												THEN ('00')
											ELSE (((ucase(T1."Make"))))
											END
										) IN ('OP')
									)
								THEN ('OP')
							WHEN (
									(
										CASE 
											WHEN (((ucase(T1."Make"))) IS NULL)
												THEN ('00')
											ELSE (((ucase(T1."Make"))))
											END
										) IN ('VW')
									)
								THEN ('VW')
							ELSE NULL
							END
						) + (
						CASE 
							WHEN (T5."MODEL_LINE" IS NOT NULL)
								THEN (T5."MODEL_LINE" + ' - ' + T5."MOD_LIN_SPECIFY")
							WHEN (T3."MODEL_LINE" IS NOT NULL)
								THEN (T3."MODEL_LINE")
							WHEN (T3."PRODUCT_GROUP" IS NOT NULL)
								THEN (T3."PRODUCT_GROUP")
							WHEN (T3."REPAIR_GROUP" IS NOT NULL)
								THEN (T3."REPAIR_GROUP")
							ELSE ('00 - ohne')
							END
						)
					)
		ELSE (
				(
					CASE 
						WHEN (T5."MODEL_LINE" IS NOT NULL)
							THEN (T5."MODEL_LINE" + ' - ' + T5."MOD_LIN_SPECIFY")
						WHEN (T3."MODEL_LINE" IS NOT NULL)
							THEN (T3."MODEL_LINE")
						WHEN (T3."PRODUCT_GROUP" IS NOT NULL)
							THEN (T3."PRODUCT_GROUP")
						WHEN (T3."REPAIR_GROUP" IS NOT NULL)
							THEN (T3."REPAIR_GROUP")
						ELSE ('00 - ohne')
						END
					)
				)
		END AS "Kostentr�ger_mit_Bez",
	(
		substring((
				(
					CASE 
						WHEN (((ucase(T1."Make"))) IS NULL)
							THEN ('00')
						ELSE (((ucase(T1."Make"))))
						END
					) + '-' + (
					CASE 
						WHEN (
								(((rtrim(T2."ACCT_NR"))) LIKE '2%')
								AND (T3."SITE" IS NULL)
								)
							THEN ('01')
						ELSE ((right('00' + (left(T3."SITE", 2)), 2)))
						END
					) + '-' + ((rtrim(T2."ACCT_NR"))) + '-' + (
					CASE 
						WHEN (
								(T3."DEPARTMENT" IS NULL)
								OR ((rtrim(T3."DEPARTMENT")) = '')
								)
							THEN ('00')
						ELSE ((rtrim(T3."DEPARTMENT")))
						END
					) + '-' + (
					CASE 
						WHEN (T3."DESTINATION" = 'FZ')
							THEN ('11')
						WHEN (
								(T3."DESTINATION" = '00')
								AND (
									(
										CASE 
											WHEN ((T3."PRICE_CODE") = '#')
												THEN ('99')
											ELSE (T3."PRICE_CODE")
											END
										) <> ''
									)
								)
							THEN (
									(
										CASE 
											WHEN ((T3."PRICE_CODE") = '#')
												THEN ('99')
											ELSE (T3."PRICE_CODE")
											END
										)
									)
						WHEN (
								(
									(T3."DESTINATION" = '00')
									AND (
										(
											CASE 
												WHEN ((T3."PRICE_CODE") = '#')
													THEN ('99')
												ELSE (T3."PRICE_CODE")
												END
											) = ''
										)
									)
								AND (T4."CUSTOMER_GROUP" <> '')
								)
							THEN (T4."CUSTOMER_GROUP")
						WHEN ((rtrim(T3."DESTINATION")) = '')
							THEN ('00')
						ELSE (T3."DESTINATION")
						END
					) + '-' + (
					upper((
							(
								rtrim(CASE 
										WHEN (
												(T5."MODEL_LINE" IS NOT NULL)
												AND (T5."MODEL_LINE" <> '')
												)
											THEN (T5."MODEL_LINE")
										WHEN (
												(T3."MODEL_LINE" IS NOT NULL)
												AND (T3."MODEL_LINE" <> '')
												)
											THEN (T3."MODEL_LINE")
										WHEN (
												(T3."PRODUCT_GROUP" IS NOT NULL)
												AND (T3."PRODUCT_GROUP" <> '')
												)
											THEN (T3."PRODUCT_GROUP")
										WHEN (
												(T3."REPAIR_GROUP" IS NOT NULL)
												AND (T3."REPAIR_GROUP" <> '')
												)
											THEN (T3."REPAIR_GROUP")
										ELSE ('00')
										END)
								)
							))
					)
				), 1, 4)
		) + '-' + (
		CASE 
			WHEN (((ucase(T1."Make"))) IS NULL)
				THEN ('00')
			ELSE (((ucase(T1."Make"))))
			END
		) + (left(T3."SITE", 2)) + (
		substring((
				CASE 
					WHEN (T3."DEPARTMENT" = '    ')
						THEN ('00')
					ELSE (T3."DEPARTMENT")
					END
				), 1, 2)
		) + (
		CASE 
			WHEN (T3."DESTINATION" = 'FZ')
				THEN ('11')
			WHEN (
					(T3."DESTINATION" = '00')
					AND (
						(
							CASE 
								WHEN ((T3."PRICE_CODE") = '#')
									THEN ('99')
								ELSE (T3."PRICE_CODE")
								END
							) <> ''
						)
					)
				THEN (
						(
							CASE 
								WHEN ((T3."PRICE_CODE") = '#')
									THEN ('99')
								ELSE (T3."PRICE_CODE")
								END
							)
						)
			WHEN (
					(
						(T3."DESTINATION" = '00')
						AND (
							(
								CASE 
									WHEN ((T3."PRICE_CODE") = '#')
										THEN ('99')
									ELSE (T3."PRICE_CODE")
									END
								) = ''
							)
						)
					AND (T4."CUSTOMER_GROUP" <> '')
					)
				THEN (T4."CUSTOMER_GROUP")
			WHEN ((rtrim(T3."DESTINATION")) = '')
				THEN ('00')
			ELSE (T3."DESTINATION")
			END
		) + (
		(
			substring((
					CASE 
						WHEN (T5."MODEL_LINE" IS NOT NULL)
							THEN (T5."MODEL_LINE" + ' - ' + T5."MOD_LIN_SPECIFY")
						WHEN (T3."MODEL_LINE" IS NOT NULL)
							THEN (T3."MODEL_LINE")
						WHEN (T3."PRODUCT_GROUP" IS NOT NULL)
							THEN (T3."PRODUCT_GROUP")
						WHEN (T3."REPAIR_GROUP" IS NOT NULL)
							THEN (T3."REPAIR_GROUP")
						ELSE ('00 - ohne')
						END
					), 1, 2)
			)
		) AS "ACCT_Detail",
	CASE 
		WHEN (
				(
					CASE 
						WHEN (((ucase(T1."Make"))) IS NULL)
							THEN ('00')
						ELSE (((ucase(T1."Make"))))
						END
					) = '00'
				)
			THEN ('ohne Marke')
		ELSE ('mit Marke')
		END AS "Buchungen ohne Marke",
	CASE 
		WHEN (
				(
					CASE 
						WHEN (T3."DEPARTMENT" = '    ')
							THEN ('00')
						ELSE (T3."DEPARTMENT")
						END
					) = '00'
				)
			THEN ('ohne KST')
		ELSE ('mit KST')
		END AS "Buchungen ohne KST",
	CASE 
		WHEN (
				(
					CASE 
						WHEN (T3."DESTINATION" = 'FZ')
							THEN ('11')
						WHEN (
								(T3."DESTINATION" = '00')
								AND (
									(
										CASE 
											WHEN ((T3."PRICE_CODE") = '#')
												THEN ('99')
											ELSE (T3."PRICE_CODE")
											END
										) <> ''
									)
								)
							THEN (
									(
										CASE 
											WHEN ((T3."PRICE_CODE") = '#')
												THEN ('99')
											ELSE (T3."PRICE_CODE")
											END
										)
									)
						WHEN (
								(
									(T3."DESTINATION" = '00')
									AND (
										(
											CASE 
												WHEN ((T3."PRICE_CODE") = '#')
													THEN ('99')
												ELSE (T3."PRICE_CODE")
												END
											) = ''
										)
									)
								AND (T4."CUSTOMER_GROUP" <> '')
								)
							THEN (T4."CUSTOMER_GROUP")
						WHEN ((rtrim(T3."DESTINATION")) = '')
							THEN ('00')
						ELSE (T3."DESTINATION")
						END
					) = '00'
				)
			THEN (('ohne Absatzkanal'))
		ELSE ('mit Absatzkanal')
		END AS "Buchungen ohne Absatzkanal",
	T3."DESTINATION" AS "Destination",
	CASE 
		WHEN (
				(
					CASE 
						WHEN (((ucase(T1."Make"))) IS NULL)
							THEN ('00')
						ELSE (((ucase(T1."Make"))))
						END
					) IN ('00')
				)
			THEN ('00 - ohne Marke')
		ELSE (
				(
					CASE 
						WHEN (((ucase(T1."Make"))) IS NULL)
							THEN ('00')
						ELSE (((ucase(T1."Make"))))
						END
					) + ' - ' + T1."Description"
				)
		END AS "Marke_mit_Bez",
	(ucase((rtrim(T3."STRATEGIC_AREA")))) AS "Strategic Area",
	(ucase(T1."Make")) AS "Marke_Strategic_Area",
	T11."Hauptbetrieb_ID" AS "Hauptbetrieb_ID",
	T11."Hauptbetrieb_Name" AS "Hauptbetrieb Name",
	T11."Standort_ID" AS "Standort Id",
	T11."Standort_Name" AS "Standort Name",
	CASE 
		WHEN ((T3."PRICE_CODE") = '#')
			THEN ('99')
		ELSE (T3."PRICE_CODE")
		END AS "Price Code"
FROM "OPTIMA"."import"."ACCOUNT_INFO" T2,
	(
		(
			(
				(
					(
						"OPTIMA"."import"."ACCT_DOC_KEY" T3 LEFT JOIN "OPTIMA"."data"."GC_Marken" T1 ON T1."Strategic_Area" = T3."STRATEGIC_AREA"
						) LEFT JOIN "OPTIMA"."import"."vPP5Q" T5 ON (T3."MODEL_LINE" = T5."MODEL_LINE")
						AND (T3."MAKE" = T5."MAKE_CD")
					) LEFT JOIN "OPTIMA"."import"."DEPARTMENT_TYPE" T7 ON T3."DEPARTMENT" = T7."DEPARTMENT_TYPE_ID"
				) LEFT JOIN "OPTIMA"."import"."AA_TRTYPE" T8 ON T3."AA_TRTYPE" = T8."AA_TRTYPE_ID"
			) LEFT JOIN "OPTIMA"."data"."GC_Department" T11 ON (T3."CLIENT_DB" = T11."Hauptbetrieb")
			AND (T3."SITE" = T11."Site")
		),
	(
		(
			(
				"OPTIMA"."import"."ACCT_DOC_DATA" T6 LEFT JOIN "OPTIMA"."import"."ACCT_DOC_SALESCLAS" T10 ON T6."REFERENCE_IDENT" = T10."REFERENCE_IDENT"
				) LEFT JOIN "OPTIMA"."import"."CUSTOMER" T4 ON T4."CUSTOMER_NUMBER" = T10."CUSTOMER_NUMBER"
			) LEFT JOIN "OPTIMA"."import"."ORDER_LINE" T9 ON (T9."ORDER_NUMBER" = T10."ORDER_NUMBER")
			AND (T9."LINE_NUMBER" = T10."ORDER_LINE_NUMBER")
		)
WHERE (T2."ACCT_NR" = T3."ACCT_NO")
	AND (T3."UNIQUE_IDENT" = T6."REFERENCE_IDENT")
	AND (T2."TYPE_ACCTT" = '2')
