SELECT "No" AS "No",
	"Name" AS "Name",
	"Account Type" AS "Account Type",
	"Department Code_2" AS "Department Code_2",
	"Make Code_2" AS "Make Code_2",
	"Income Balance" AS "Income Balance",
	"Entry No" AS "Entry No",
	"G L Account No" AS "G L Account No",
	"Posting Date" AS "Posting Date",
	"Document Type" AS "Document Type",
	"Document No" AS "Document No",
	"Description" AS "Description",
	"Amount" AS "Amount",
	"Bal Account No" AS "Bal Account No",
	"Department Code" AS "Department Code",
	"Make Code" AS "Make Code",
	"User Id" AS "User Id",
	"Source Code" AS "Source Code",
	"Quantity" AS "Quantity",
	"Debit Amount" AS "Debit Amount",
	"Credit Amount" AS "Credit Amount",
	"Document Date" AS "Document Date",
	"Source Type" AS "Source Type",
	"Source No" AS "Source No",
	"No Series" AS "No Series",
	"Branch Code" AS "Branch Code",
	"Main Area" AS "Main Area",
	"Vin" AS "Vin",
	"Book No" AS "Book No",
	"Veh Source Code" AS "Veh Source Code",
	"Betrag" AS "Betrag",
	"Vin_Vehicle" AS "Vin_Vehicle",
	"Vehicle Status" AS "Vehicle Status",
	"Model_ori" AS "Model_ori",
	"Type" AS "Type",
	"Class" AS "Class",
	"Model No" AS "Model No",
	"Hauptbetrieb" AS "Hauptbetrieb",
	"Standort_alt" AS "Standort_alt",
	"Make Code_Vehicle" AS "Make Code_Vehicle",
	"Fabrikat_ori" AS "Fabrikat_ori",
	"Model" AS "Model",
	"Market Segment Code" AS "Market Segment Code",
	"Modellbez" AS "Modellbez",
	"Fahrzeugart" AS "Fahrzeugart",
	"Vat Prod Posting Group" AS "Vat Prod Posting Group",
	"Fahrzeugtyp_alt" AS "Fahrzeugtyp_alt",
	"FZG" AS "FZG",
	"Location Code" AS "Location Code",
	"VB_Einkauf" AS "VB_Einkauf",
	"Purchase Receipt Date" AS "Purchase Receipt Date",
	"Standtage_ori" AS "Standtage_ori",
	"Standtagestaffel" AS "Standtagestaffel",
	"Initial Registration" AS "Initial Registration",
	"EZ/Eingang" AS "EZ/Eingang",
	"Polster" AS "Polster",
	"Farbe" AS "Farbe",
	"Einsatz_ori" AS "Einsatz_ori",
	"Heute" AS "Heute",
	"Fahrzeugstatus" AS "Fahrzeugstatus",
	"FZG-Liste" AS "FZG-Liste",
	"Anzahl" AS "Anzahl",
	"Standtage" AS "Standtage",
	"Inventory Posting Group" AS "Inventory Posting Group",
	"Date Of Sale" AS "Date Of Sale",
	"Invoice Date" AS "Invoice Date",
	"Customer No" AS "Customer No",
	"No_Customer" AS "No_Customer",
	"Name_Customer" AS "Name_Customer",
	"Kunde" AS "Kunde",
	"Customer Type" AS "Customer Type",
	"Kundenart" AS "Kundenart",
	"Old Customer No_2" AS "Old Customer No_2",
	"Old Customer No" AS "Old Customer No",
	"No_Vorbesitzer" AS "No_Vorbesitzer",
	"Name_Vorbesitzer" AS "Name_Vorbesitzer",
	"Vorbesitzer" AS "Vorbesitzer",
	"Engine Code" AS "Engine Code",
	"Motor Code" AS "Motor Code",
	"Gesch�ftsart" AS "Gesch�ftsart",
	"FZG_Liste_1_ori" AS "FZG_Liste_1_ori",
	"FZG_Liste_2" AS "FZG_Liste_2",
	"FZG_Liste_3" AS "FZG_Liste_3",
	"FZG_Liste_4" AS "FZG_Liste_4",
	"Erl�s" AS "Erl�s",
	"Einsatz" AS "Einsatz",
	"EK Fahrzeug" AS "EK Fahrzeug",
	"Bonus" AS "Bonus",
	"int. Kosten" AS "int. Kosten",
	"Current Branch Book No" AS "Current Branch Book No",
	"Current Book No" AS "Current Book No",
	"Summe EK-FZG" AS "Summe EK-FZG",
	"Fabrikat" AS "Fabrikat",
	"Buchnummer gleich_ja_nein" AS "Buchnummer gleich_ja_nein",
	"Menge1" AS "Menge1",
	"Menge2" AS "Menge2",
	"Menge3" AS "Menge3",
	"Menge4" AS "Menge4",
	"VIN + PostingDate" AS "VIN + PostingDate",
	SUM("Menge4") OVER (PARTITION BY "Vin") AS "Summe Menge4",
	"Menge_2_test" AS "Menge_2_test",
	"Menge3_test" AS "Menge3_test",
	"Menge4_test" AS "Menge4_test",
	"Fahrzeugart_Schmidt" AS "Fahrzeugart_Schmidt",
	"Salespers Purch Code_VLE" AS "Salespers Purch Code_VLE",
	"Code_f�r_VEH_Ledger_Entry" AS "Code_f�r_VEH_Ledger_Entry",
	"Name_f�r_VEH_Ledger_Entry" AS "Name_f�r_VEH_Ledger_Entry",
	"Verk�ufer" AS "Verk�ufer",
	"FZG_Liste_1_falsch" AS "FZG_Liste_1_falsch",
	"FZG_Liste_0_ori" AS "FZG_Liste_0_ori",
	"FZG_Liste_1" AS "FZG_Liste_1",
	"FZG_Liste_0" AS "FZG_Liste_0",
	"Beleg" AS "Beleg",
	"Standort_FIBU" AS "Standort_FIBU",
	"Fahrzeugart_neu" AS "Fahrzeugart_neu",
	"Standort" AS "Standort",
	"Summe_Betrag" AS "Summe_Betrag",
	"Country Code_Kunde" AS "Country Code_Kunde",
	"Vat Bus Posting Group_Kunde" AS "Vat Bus Posting Group_Kunde",
	"FZG_Liste_5_ori" AS "FZG_Liste_5_ori",
	"Customer Group Code" AS "Customer Group Code",
	"FZG_Liste_5" AS "FZG_Liste_5",
	"FZG_Liste_6" AS "FZG_Liste_6",
	"FZG_Liste_7" AS "FZG_Liste_7",
	"FZG_Detail" AS "FZG_Detail",
	"Anz. S�tze" AS "Anz. S�tze",
	"Menge_final" AS "Menge_final",
	"No_Item" AS "No_Item",
	"Description_Item" AS "Description_Item",
	"Vehicle Type Code_Item" AS "Vehicle Type Code_Item",
	"Modell_zwischen" AS "Modell_zwischen",
	"Vehicle Category Code" AS "Vehicle Category Code",
	"Summe Erl�s FZG" AS "Summe Erl�s FZG",
	"Erl�se FZG" AS "Erl�se FZG",
	"Modell_final" AS "Modell_final",
	"Fahrzeugtyp" AS "Fahrzeugtyp"
FROM (
	SELECT "No" AS "No",
		"Name" AS "Name",
		"Account Type" AS "Account Type",
		"Department Code_2" AS "Department Code_2",
		"Make Code_2" AS "Make Code_2",
		"Income Balance" AS "Income Balance",
		"Entry No" AS "Entry No",
		"G L Account No" AS "G L Account No",
		"Posting Date" AS "Posting Date",
		"Document Type" AS "Document Type",
		"Document No" AS "Document No",
		"Description" AS "Description",
		"Amount" AS "Amount",
		"Bal Account No" AS "Bal Account No",
		"Department Code" AS "Department Code",
		"Make Code" AS "Make Code",
		"User Id" AS "User Id",
		"Source Code" AS "Source Code",
		"Quantity" AS "Quantity",
		"Debit Amount" AS "Debit Amount",
		"Credit Amount" AS "Credit Amount",
		"Document Date" AS "Document Date",
		"Source Type" AS "Source Type",
		"Source No" AS "Source No",
		"No Series" AS "No Series",
		"Branch Code" AS "Branch Code",
		"Main Area" AS "Main Area",
		"Vin" AS "Vin",
		"Book No" AS "Book No",
		"Veh Source Code" AS "Veh Source Code",
		"Betrag" AS "Betrag",
		"Vin_Vehicle" AS "Vin_Vehicle",
		"Vehicle Status" AS "Vehicle Status",
		"Model_ori" AS "Model_ori",
		"Type" AS "Type",
		"Class" AS "Class",
		"Model No" AS "Model No",
		"Hauptbetrieb" AS "Hauptbetrieb",
		"Standort_alt" AS "Standort_alt",
		"Make Code_Vehicle" AS "Make Code_Vehicle",
		"Fabrikat_ori" AS "Fabrikat_ori",
		"Model" AS "Model",
		"Market Segment Code" AS "Market Segment Code",
		"Modellbez" AS "Modellbez",
		"Fahrzeugart" AS "Fahrzeugart",
		"Vat Prod Posting Group" AS "Vat Prod Posting Group",
		"Fahrzeugtyp_alt" AS "Fahrzeugtyp_alt",
		"FZG" AS "FZG",
		"Location Code" AS "Location Code",
		"VB_Einkauf" AS "VB_Einkauf",
		"Purchase Receipt Date" AS "Purchase Receipt Date",
		"Standtage_ori" AS "Standtage_ori",
		"Standtagestaffel" AS "Standtagestaffel",
		"Initial Registration" AS "Initial Registration",
		"EZ/Eingang" AS "EZ/Eingang",
		"Polster" AS "Polster",
		"Farbe" AS "Farbe",
		"Einsatz_ori" AS "Einsatz_ori",
		"Heute" AS "Heute",
		"Fahrzeugstatus" AS "Fahrzeugstatus",
		"FZG-Liste" AS "FZG-Liste",
		"Anzahl" AS "Anzahl",
		"Standtage" AS "Standtage",
		"Inventory Posting Group" AS "Inventory Posting Group",
		"Date Of Sale" AS "Date Of Sale",
		"Invoice Date" AS "Invoice Date",
		"Customer No" AS "Customer No",
		"No_Customer" AS "No_Customer",
		"Name_Customer" AS "Name_Customer",
		"Kunde" AS "Kunde",
		"Customer Type" AS "Customer Type",
		"Kundenart" AS "Kundenart",
		"Old Customer No_2" AS "Old Customer No_2",
		"Old Customer No" AS "Old Customer No",
		"No_Vorbesitzer" AS "No_Vorbesitzer",
		"Name_Vorbesitzer" AS "Name_Vorbesitzer",
		"Vorbesitzer" AS "Vorbesitzer",
		"Engine Code" AS "Engine Code",
		"Motor Code" AS "Motor Code",
		"Gesch�ftsart" AS "Gesch�ftsart",
		"FZG_Liste_1_ori" AS "FZG_Liste_1_ori",
		"FZG_Liste_2" AS "FZG_Liste_2",
		"FZG_Liste_3" AS "FZG_Liste_3",
		"FZG_Liste_4" AS "FZG_Liste_4",
		"Erl�s" AS "Erl�s",
		"Einsatz" AS "Einsatz",
		"EK Fahrzeug" AS "EK Fahrzeug",
		"Bonus" AS "Bonus",
		"int. Kosten" AS "int. Kosten",
		"Current Branch Book No" AS "Current Branch Book No",
		"Current Book No" AS "Current Book No",
		"Summe EK-FZG" AS "Summe EK-FZG",
		"Fabrikat" AS "Fabrikat",
		"Buchnummer gleich_ja_nein" AS "Buchnummer gleich_ja_nein",
		"Menge1" AS "Menge1",
		"Menge2" AS "Menge2",
		"Menge3" AS "Menge3",
		"Menge4" AS "Menge4",
		"VIN + PostingDate" AS "VIN + PostingDate",
		COUNT("Vin") OVER (PARTITION BY c248) AS "Menge_2_test",
		("Menge1" / COUNT("Vin") OVER (PARTITION BY c248)) AS "Menge3_test",
		CASE 
			WHEN ("Document No" LIKE 'VGGF%')
				THEN (("Menge1" / COUNT("Vin") OVER (PARTITION BY c248)) * - 1)
			ELSE ("Menge1" / COUNT("Vin") OVER (PARTITION BY c248))
			END AS "Menge4_test",
		"Fahrzeugart_Schmidt" AS "Fahrzeugart_Schmidt",
		"Salespers Purch Code_VLE" AS "Salespers Purch Code_VLE",
		"Code_f�r_VEH_Ledger_Entry" AS "Code_f�r_VEH_Ledger_Entry",
		"Name_f�r_VEH_Ledger_Entry" AS "Name_f�r_VEH_Ledger_Entry",
		"Verk�ufer" AS "Verk�ufer",
		"FZG_Liste_1_falsch" AS "FZG_Liste_1_falsch",
		"FZG_Liste_0_ori" AS "FZG_Liste_0_ori",
		"FZG_Liste_1" AS "FZG_Liste_1",
		"FZG_Liste_0" AS "FZG_Liste_0",
		"Beleg" AS "Beleg",
		"Standort_FIBU" AS "Standort_FIBU",
		"Fahrzeugart_neu" AS "Fahrzeugart_neu",
		"Standort" AS "Standort",
		"Summe_Betrag" AS "Summe_Betrag",
		"Country Code_Kunde" AS "Country Code_Kunde",
		"Vat Bus Posting Group_Kunde" AS "Vat Bus Posting Group_Kunde",
		"FZG_Liste_5_ori" AS "FZG_Liste_5_ori",
		"Customer Group Code" AS "Customer Group Code",
		"FZG_Liste_5" AS "FZG_Liste_5",
		"FZG_Liste_6" AS "FZG_Liste_6",
		"FZG_Liste_7" AS "FZG_Liste_7",
		"FZG_Detail" AS "FZG_Detail",
		"Anz. S�tze" AS "Anz. S�tze",
		"Menge_final" AS "Menge_final",
		"No_Item" AS "No_Item",
		"Description_Item" AS "Description_Item",
		"Vehicle Type Code_Item" AS "Vehicle Type Code_Item",
		"Modell_zwischen" AS "Modell_zwischen",
		"Vehicle Category Code" AS "Vehicle Category Code",
		"Summe Erl�s FZG" AS "Summe Erl�s FZG",
		"Erl�se FZG" AS "Erl�se FZG",
		"Modell_final" AS "Modell_final",
		"Fahrzeugtyp" AS "Fahrzeugtyp"
	FROM (
		SELECT "No" AS "No",
			"Name" AS "Name",
			"Account Type" AS "Account Type",
			"Department Code_2" AS "Department Code_2",
			"Make Code_2" AS "Make Code_2",
			"Income Balance" AS "Income Balance",
			"Entry No" AS "Entry No",
			"G L Account No" AS "G L Account No",
			"Posting Date" AS "Posting Date",
			"Document Type" AS "Document Type",
			"Document No" AS "Document No",
			"Description" AS "Description",
			"Amount" AS "Amount",
			"Bal Account No" AS "Bal Account No",
			"Department Code" AS "Department Code",
			"Make Code" AS "Make Code",
			"User Id" AS "User Id",
			"Source Code" AS "Source Code",
			"Quantity" AS "Quantity",
			"Debit Amount" AS "Debit Amount",
			"Credit Amount" AS "Credit Amount",
			"Document Date" AS "Document Date",
			"Source Type" AS "Source Type",
			"Source No" AS "Source No",
			"No Series" AS "No Series",
			"Branch Code" AS "Branch Code",
			"Main Area" AS "Main Area",
			"Vin" AS "Vin",
			"Book No" AS "Book No",
			"Veh Source Code" AS "Veh Source Code",
			"Betrag" AS "Betrag",
			"Vin_Vehicle" AS "Vin_Vehicle",
			"Vehicle Status" AS "Vehicle Status",
			"Model_ori" AS "Model_ori",
			"Type" AS "Type",
			"Class" AS "Class",
			"Model No" AS "Model No",
			"Hauptbetrieb" AS "Hauptbetrieb",
			"Standort_alt" AS "Standort_alt",
			"Make Code_Vehicle" AS "Make Code_Vehicle",
			"Fabrikat_ori" AS "Fabrikat_ori",
			"Model" AS "Model",
			"Market Segment Code" AS "Market Segment Code",
			"Modellbez" AS "Modellbez",
			"Fahrzeugart" AS "Fahrzeugart",
			"Vat Prod Posting Group" AS "Vat Prod Posting Group",
			"Fahrzeugtyp_alt" AS "Fahrzeugtyp_alt",
			"FZG" AS "FZG",
			"Location Code" AS "Location Code",
			"VB_Einkauf" AS "VB_Einkauf",
			"Purchase Receipt Date" AS "Purchase Receipt Date",
			"Standtage_ori" AS "Standtage_ori",
			"Standtagestaffel" AS "Standtagestaffel",
			"Initial Registration" AS "Initial Registration",
			"EZ/Eingang" AS "EZ/Eingang",
			"Polster" AS "Polster",
			"Farbe" AS "Farbe",
			"Einsatz_ori" AS "Einsatz_ori",
			"Heute" AS "Heute",
			"Fahrzeugstatus" AS "Fahrzeugstatus",
			"FZG-Liste" AS "FZG-Liste",
			"Anzahl" AS "Anzahl",
			"Standtage" AS "Standtage",
			"Inventory Posting Group" AS "Inventory Posting Group",
			"Date Of Sale" AS "Date Of Sale",
			"Invoice Date" AS "Invoice Date",
			"Customer No" AS "Customer No",
			"No_Customer" AS "No_Customer",
			"Name_Customer" AS "Name_Customer",
			"Kunde" AS "Kunde",
			"Customer Type" AS "Customer Type",
			"Kundenart" AS "Kundenart",
			"Old Customer No_2" AS "Old Customer No_2",
			"Old Customer No" AS "Old Customer No",
			"No_Vorbesitzer" AS "No_Vorbesitzer",
			"Name_Vorbesitzer" AS "Name_Vorbesitzer",
			"Vorbesitzer" AS "Vorbesitzer",
			"Engine Code" AS "Engine Code",
			"Motor Code" AS "Motor Code",
			"Gesch�ftsart" AS "Gesch�ftsart",
			"FZG_Liste_1_ori" AS "FZG_Liste_1_ori",
			"FZG_Liste_2" AS "FZG_Liste_2",
			"FZG_Liste_3" AS "FZG_Liste_3",
			"FZG_Liste_4" AS "FZG_Liste_4",
			"Erl�s" AS "Erl�s",
			"Einsatz" AS "Einsatz",
			"EK Fahrzeug" AS "EK Fahrzeug",
			"Bonus" AS "Bonus",
			"int. Kosten" AS "int. Kosten",
			"Current Branch Book No" AS "Current Branch Book No",
			"Current Book No" AS "Current Book No",
			"Summe EK-FZG" AS "Summe EK-FZG",
			"Fabrikat" AS "Fabrikat",
			"Buchnummer gleich_ja_nein" AS "Buchnummer gleich_ja_nein",
			"Menge1" AS "Menge1",
			COUNT("Vin") OVER (PARTITION BY "VIN + PostingDate") AS "Menge2",
			("Menge1" / COUNT("Vin") OVER (PARTITION BY "VIN + PostingDate")) AS "Menge3",
			CASE 
				WHEN ("Document No" LIKE 'VGGF%')
					THEN (("Menge1" / COUNT("Vin") OVER (PARTITION BY "VIN + PostingDate")) * - 1)
				ELSE ("Menge1" / COUNT("Vin") OVER (PARTITION BY "VIN + PostingDate"))
				END AS "Menge4",
			"VIN + PostingDate" AS "VIN + PostingDate",
			"Fahrzeugart_Schmidt" AS "Fahrzeugart_Schmidt",
			"Salespers Purch Code_VLE" AS "Salespers Purch Code_VLE",
			"Code_f�r_VEH_Ledger_Entry" AS "Code_f�r_VEH_Ledger_Entry",
			"Name_f�r_VEH_Ledger_Entry" AS "Name_f�r_VEH_Ledger_Entry",
			"Verk�ufer" AS "Verk�ufer",
			"FZG_Liste_1_falsch" AS "FZG_Liste_1_falsch",
			"FZG_Liste_0_ori" AS "FZG_Liste_0_ori",
			"FZG_Liste_1" AS "FZG_Liste_1",
			"FZG_Liste_0" AS "FZG_Liste_0",
			"Beleg" AS "Beleg",
			"Standort_FIBU" AS "Standort_FIBU",
			"Fahrzeugart_neu" AS "Fahrzeugart_neu",
			"Standort" AS "Standort",
			"Summe_Betrag" AS "Summe_Betrag",
			"Country Code_Kunde" AS "Country Code_Kunde",
			"Vat Bus Posting Group_Kunde" AS "Vat Bus Posting Group_Kunde",
			"FZG_Liste_5_ori" AS "FZG_Liste_5_ori",
			"Customer Group Code" AS "Customer Group Code",
			"FZG_Liste_5" AS "FZG_Liste_5",
			"FZG_Liste_6" AS "FZG_Liste_6",
			"FZG_Liste_7" AS "FZG_Liste_7",
			"FZG_Detail" AS "FZG_Detail",
			"Anz. S�tze" AS "Anz. S�tze",
			"Menge_final" AS "Menge_final",
			"No_Item" AS "No_Item",
			"Description_Item" AS "Description_Item",
			"Vehicle Type Code_Item" AS "Vehicle Type Code_Item",
			"Modell_zwischen" AS "Modell_zwischen",
			"Vehicle Category Code" AS "Vehicle Category Code",
			"Summe Erl�s FZG" AS "Summe Erl�s FZG",
			"Erl�se FZG" AS "Erl�se FZG",
			"Modell_final" AS "Modell_final",
			"Fahrzeugtyp" AS "Fahrzeugtyp",
			c248 AS c248
		FROM (
			SELECT "No" AS "No",
				"Name" AS "Name",
				"Account Type" AS "Account Type",
				"Department Code_2" AS "Department Code_2",
				"Make Code_2" AS "Make Code_2",
				"Income Balance" AS "Income Balance",
				"Entry No" AS "Entry No",
				"G L Account No" AS "G L Account No",
				"Posting Date" AS "Posting Date",
				"Document Type" AS "Document Type",
				"Document No" AS "Document No",
				"Description" AS "Description",
				"Amount" AS "Amount",
				"Bal Account No" AS "Bal Account No",
				"Department Code" AS "Department Code",
				"Make Code" AS "Make Code",
				"User Id" AS "User Id",
				"Source Code" AS "Source Code",
				"Quantity" AS "Quantity",
				"Debit Amount" AS "Debit Amount",
				"Credit Amount" AS "Credit Amount",
				"Document Date" AS "Document Date",
				"Source Type" AS "Source Type",
				"Source No" AS "Source No",
				"No Series" AS "No Series",
				"Branch Code" AS "Branch Code",
				"Main Area" AS "Main Area",
				"Vin" AS "Vin",
				"Book No" AS "Book No",
				"Veh Source Code" AS "Veh Source Code",
				"Betrag" AS "Betrag",
				"Vin_Vehicle" AS "Vin_Vehicle",
				"Vehicle Status" AS "Vehicle Status",
				"Model_ori" AS "Model_ori",
				"Type" AS "Type",
				"Class" AS "Class",
				"Model No" AS "Model No",
				"Hauptbetrieb" AS "Hauptbetrieb",
				"Standort_alt" AS "Standort_alt",
				"Make Code_Vehicle" AS "Make Code_Vehicle",
				"Fabrikat_ori" AS "Fabrikat_ori",
				"Model" AS "Model",
				"Market Segment Code" AS "Market Segment Code",
				"Modellbez" AS "Modellbez",
				"Fahrzeugart" AS "Fahrzeugart",
				"Vat Prod Posting Group" AS "Vat Prod Posting Group",
				"Fahrzeugtyp_alt" AS "Fahrzeugtyp_alt",
				"FZG" AS "FZG",
				"Location Code" AS "Location Code",
				"VB_Einkauf" AS "VB_Einkauf",
				"Purchase Receipt Date" AS "Purchase Receipt Date",
				"Standtage_ori" AS "Standtage_ori",
				"Standtagestaffel" AS "Standtagestaffel",
				"Initial Registration" AS "Initial Registration",
				"EZ/Eingang" AS "EZ/Eingang",
				"Polster" AS "Polster",
				"Farbe" AS "Farbe",
				"Einsatz_ori" AS "Einsatz_ori",
				"Heute" AS "Heute",
				"Fahrzeugstatus" AS "Fahrzeugstatus",
				"FZG-Liste" AS "FZG-Liste",
				COUNT("Standtage_ori") OVER (PARTITION BY "Vin") AS "Anzahl",
				("Standtage_ori" / COUNT("Standtage_ori") OVER (PARTITION BY "Vin")) AS "Standtage",
				"Inventory Posting Group" AS "Inventory Posting Group",
				"Date Of Sale" AS "Date Of Sale",
				"Invoice Date" AS "Invoice Date",
				"Customer No" AS "Customer No",
				"No_Customer" AS "No_Customer",
				"Name_Customer" AS "Name_Customer",
				"Kunde" AS "Kunde",
				"Customer Type" AS "Customer Type",
				"Kundenart" AS "Kundenart",
				"Old Customer No_2" AS "Old Customer No_2",
				"Old Customer No" AS "Old Customer No",
				"No_Vorbesitzer" AS "No_Vorbesitzer",
				"Name_Vorbesitzer" AS "Name_Vorbesitzer",
				"Vorbesitzer" AS "Vorbesitzer",
				"Engine Code" AS "Engine Code",
				"Motor Code" AS "Motor Code",
				"Gesch�ftsart" AS "Gesch�ftsart",
				"FZG_Liste_1_ori" AS "FZG_Liste_1_ori",
				"FZG_Liste_2" AS "FZG_Liste_2",
				"FZG_Liste_3" AS "FZG_Liste_3",
				"FZG_Liste_4" AS "FZG_Liste_4",
				"Erl�s" AS "Erl�s",
				"Einsatz" AS "Einsatz",
				"EK Fahrzeug" AS "EK Fahrzeug",
				"Bonus" AS "Bonus",
				"int. Kosten" AS "int. Kosten",
				"Current Branch Book No" AS "Current Branch Book No",
				"Current Book No" AS "Current Book No",
				SUM("EK Fahrzeug") OVER (PARTITION BY "Vin") AS "Summe EK-FZG",
				"Fabrikat" AS "Fabrikat",
				"Buchnummer gleich_ja_nein" AS "Buchnummer gleich_ja_nein",
				"Menge1" AS "Menge1",
				"VIN + PostingDate" AS "VIN + PostingDate",
				"Fahrzeugart_Schmidt" AS "Fahrzeugart_Schmidt",
				"Salespers Purch Code_VLE" AS "Salespers Purch Code_VLE",
				"Code_f�r_VEH_Ledger_Entry" AS "Code_f�r_VEH_Ledger_Entry",
				"Name_f�r_VEH_Ledger_Entry" AS "Name_f�r_VEH_Ledger_Entry",
				"Verk�ufer" AS "Verk�ufer",
				"FZG_Liste_1_falsch" AS "FZG_Liste_1_falsch",
				"FZG_Liste_0_ori" AS "FZG_Liste_0_ori",
				"FZG_Liste_1" AS "FZG_Liste_1",
				"FZG_Liste_0" AS "FZG_Liste_0",
				"Beleg" AS "Beleg",
				"Standort_FIBU" AS "Standort_FIBU",
				"Fahrzeugart_neu" AS "Fahrzeugart_neu",
				"Standort" AS "Standort",
				"Summe_Betrag" AS "Summe_Betrag",
				"Country Code_Kunde" AS "Country Code_Kunde",
				"Vat Bus Posting Group_Kunde" AS "Vat Bus Posting Group_Kunde",
				"FZG_Liste_5_ori" AS "FZG_Liste_5_ori",
				"Customer Group Code" AS "Customer Group Code",
				"FZG_Liste_5" AS "FZG_Liste_5",
				"FZG_Liste_6" AS "FZG_Liste_6",
				"FZG_Liste_7" AS "FZG_Liste_7",
				"FZG_Detail" AS "FZG_Detail",
				COUNT("No") OVER (PARTITION BY "Vin") AS "Anz. S�tze",
				("Menge1" / COUNT("No") OVER (PARTITION BY "Vin")) AS "Menge_final",
				"No_Item" AS "No_Item",
				"Description_Item" AS "Description_Item",
				"Vehicle Type Code_Item" AS "Vehicle Type Code_Item",
				"Modell_zwischen" AS "Modell_zwischen",
				"Vehicle Category Code" AS "Vehicle Category Code",
				SUM("Erl�se FZG") OVER (PARTITION BY "Vin") AS "Summe Erl�s FZG",
				"Erl�se FZG" AS "Erl�se FZG",
				"Modell_final" AS "Modell_final",
				"Fahrzeugtyp" AS "Fahrzeugtyp",
				(c137) AS c248
			FROM (
				SELECT "No" AS "No",
					"Name" AS "Name",
					"Account Type" AS "Account Type",
					"Department Code_2" AS "Department Code_2",
					"Make Code_2" AS "Make Code_2",
					"Income Balance" AS "Income Balance",
					"Entry No" AS "Entry No",
					"G L Account No" AS "G L Account No",
					"Posting Date" AS "Posting Date",
					"Document Type" AS "Document Type",
					"Document No" AS "Document No",
					"Description" AS "Description",
					"Amount" AS "Amount",
					"Bal Account No" AS "Bal Account No",
					"Department Code" AS "Department Code",
					"Make Code" AS "Make Code",
					"User Id" AS "User Id",
					"Source Code" AS "Source Code",
					"Quantity" AS "Quantity",
					"Debit Amount" AS "Debit Amount",
					"Credit Amount" AS "Credit Amount",
					"Document Date" AS "Document Date",
					"Source Type" AS "Source Type",
					"Source No" AS "Source No",
					"No Series" AS "No Series",
					"Branch Code" AS "Branch Code",
					"Main Area" AS "Main Area",
					"Vin" AS "Vin",
					"Book No" AS "Book No",
					"Veh Source Code" AS "Veh Source Code",
					"Betrag" AS "Betrag",
					"Vin_Vehicle" AS "Vin_Vehicle",
					"Vehicle Status" AS "Vehicle Status",
					"Model_ori" AS "Model_ori",
					"Type" AS "Type",
					"Class" AS "Class",
					"Model No" AS "Model No",
					"Hauptbetrieb" AS "Hauptbetrieb",
					"Standort_alt" AS "Standort_alt",
					"Make Code_Vehicle" AS "Make Code_Vehicle",
					"Fabrikat_ori" AS "Fabrikat_ori",
					"Model" AS "Model",
					"Market Segment Code" AS "Market Segment Code",
					"Modellbez" AS "Modellbez",
					"Fahrzeugart" AS "Fahrzeugart",
					"Vat Prod Posting Group" AS "Vat Prod Posting Group",
					"Fahrzeugtyp_alt" AS "Fahrzeugtyp_alt",
					"FZG" AS "FZG",
					"Location Code" AS "Location Code",
					"VB_Einkauf" AS "VB_Einkauf",
					"Purchase Receipt Date" AS "Purchase Receipt Date",
					"Standtage_ori" AS "Standtage_ori",
					"Standtagestaffel" AS "Standtagestaffel",
					"Initial Registration" AS "Initial Registration",
					"EZ/Eingang" AS "EZ/Eingang",
					"Polster" AS "Polster",
					"Farbe" AS "Farbe",
					"Einsatz_ori" AS "Einsatz_ori",
					"Heute" AS "Heute",
					"Fahrzeugstatus" AS "Fahrzeugstatus",
					"FZG-Liste" AS "FZG-Liste",
					"Inventory Posting Group" AS "Inventory Posting Group",
					"Date Of Sale" AS "Date Of Sale",
					"Invoice Date" AS "Invoice Date",
					"Customer No" AS "Customer No",
					"No_Customer" AS "No_Customer",
					"Name_Customer" AS "Name_Customer",
					"Kunde" AS "Kunde",
					"Customer Type" AS "Customer Type",
					"Kundenart" AS "Kundenart",
					"Old Customer No_2" AS "Old Customer No_2",
					"Old Customer No" AS "Old Customer No",
					"No_Vorbesitzer" AS "No_Vorbesitzer",
					"Name_Vorbesitzer" AS "Name_Vorbesitzer",
					"Vorbesitzer" AS "Vorbesitzer",
					"Engine Code" AS "Engine Code",
					"Motor Code" AS "Motor Code",
					"Gesch�ftsart" AS "Gesch�ftsart",
					"FZG_Liste_1_ori" AS "FZG_Liste_1_ori",
					"FZG_Liste_2" AS "FZG_Liste_2",
					"FZG_Liste_3" AS "FZG_Liste_3",
					"FZG_Liste_4" AS "FZG_Liste_4",
					"Erl�s" AS "Erl�s",
					"Einsatz" AS "Einsatz",
					"EK Fahrzeug" AS "EK Fahrzeug",
					"Bonus" AS "Bonus",
					"int. Kosten" AS "int. Kosten",
					"Current Branch Book No" AS "Current Branch Book No",
					"Current Book No" AS "Current Book No",
					"Fabrikat" AS "Fabrikat",
					"Buchnummer gleich_ja_nein" AS "Buchnummer gleich_ja_nein",
					"Menge1" AS "Menge1",
					"VIN + PostingDate" AS "VIN + PostingDate",
					"Fahrzeugart_Schmidt" AS "Fahrzeugart_Schmidt",
					"Salespers Purch Code_VLE" AS "Salespers Purch Code_VLE",
					"Code_f�r_VEH_Ledger_Entry" AS "Code_f�r_VEH_Ledger_Entry",
					"Name_f�r_VEH_Ledger_Entry" AS "Name_f�r_VEH_Ledger_Entry",
					"Verk�ufer" AS "Verk�ufer",
					"FZG_Liste_1_falsch" AS "FZG_Liste_1_falsch",
					"FZG_Liste_0_ori" AS "FZG_Liste_0_ori",
					"FZG_Liste_1" AS "FZG_Liste_1",
					"FZG_Liste_0" AS "FZG_Liste_0",
					"Beleg" AS "Beleg",
					"Standort_FIBU" AS "Standort_FIBU",
					"Fahrzeugart_neu" AS "Fahrzeugart_neu",
					"Standort" AS "Standort",
					"Summe_Betrag" AS "Summe_Betrag",
					"Country Code_Kunde" AS "Country Code_Kunde",
					"Vat Bus Posting Group_Kunde" AS "Vat Bus Posting Group_Kunde",
					"FZG_Liste_5_ori" AS "FZG_Liste_5_ori",
					"Customer Group Code" AS "Customer Group Code",
					"FZG_Liste_5" AS "FZG_Liste_5",
					"FZG_Liste_6" AS "FZG_Liste_6",
					"FZG_Liste_7" AS "FZG_Liste_7",
					"FZG_Detail" AS "FZG_Detail",
					"No_Item" AS "No_Item",
					"Description_Item" AS "Description_Item",
					"Vehicle Type Code_Item" AS "Vehicle Type Code_Item",
					"Modell_zwischen" AS "Modell_zwischen",
					"Vehicle Category Code" AS "Vehicle Category Code",
					"Erl�se FZG" AS "Erl�se FZG",
					"Modell_final" AS "Modell_final",
					"Fahrzeugtyp" AS "Fahrzeugtyp",
					c137 AS c137,
					SUM("Erl�se FZG") OVER (PARTITION BY "Vin") AS c138
				FROM (
					SELECT "No",
						"Name",
						"Account Type",
						"Department Code_2",
						"Make Code_2",
						"Income Balance",
						"Entry No",
						"G L Account No",
						"Posting Date",
						"Document Type",
						"Document No",
						"Description",
						"Amount",
						"Bal Account No",
						"Department Code",
						"Make Code",
						"User Id",
						"Source Code",
						"Quantity",
						"Debit Amount",
						"Credit Amount",
						"Document Date",
						"Source Type",
						"Source No",
						"No Series",
						"Branch Code",
						"Main Area",
						"Vin",
						"Book No",
						"Veh Source Code",
						"Betrag",
						"Vin_Vehicle",
						"Vehicle Status",
						"Model_ori",
						"Type",
						"Class",
						"Model No",
						'1' AS "Hauptbetrieb",
						"Standort_alt",
						"Make Code_Vehicle",
						"Make Code_Vehicle" AS "Fabrikat_ori",
						"Model",
						"Market Segment Code",
						"Model_ori" AS "Modellbez",
						"Fahrzeugart",
						"Vat Prod Posting Group",
						"Fahrzeugtyp_alt",
						"FZG",
						"Location Code",
						'' AS "VB_Einkauf",
						"Purchase Receipt Date",
						"Standtage_ori",
						"Standtagestaffel",
						"Initial Registration",
						"EZ/Eingang",
						'' AS "Polster",
						'' AS "Farbe",
						"Betrag" AS "Einsatz_ori",
						(getdate()) AS "Heute",
						'Bestand' AS "Fahrzeugstatus",
						"FZG-Liste",
						"Inventory Posting Group",
						"Date Of Sale",
						"Invoice Date",
						"Customer No",
						"No_Customer",
						"Name_Customer",
						"Kunde",
						"Customer Type",
						"Kundenart",
						"Old Customer No_2",
						"Old Customer No_2" AS "Old Customer No",
						"No_Vorbesitzer",
						"Name_Vorbesitzer",
						"Name_Vorbesitzer" AS "Vorbesitzer",
						"Engine Code",
						"Engine Code" AS "Motor Code",
						'' AS "Gesch�ftsart",
						"FZG_Liste_1_ori",
						"FZG_Liste_2",
						"Model_ori" AS "FZG_Liste_3",
						"FZG_Liste_4",
						"Erl�s",
						"Einsatz",
						"EK Fahrzeug",
						"Bonus",
						"int. Kosten",
						"Current Branch Book No",
						"Current Book No",
						"Fabrikat",
						"Buchnummer gleich_ja_nein",
						1 AS "Menge1",
						"VIN + PostingDate" AS "VIN + PostingDate",
						"Fahrzeugart_Schmidt",
						"Salespers Purch Code_VLE",
						"Code_f�r_VEH_Ledger_Entry",
						"Name_f�r_VEH_Ledger_Entry",
						"Verk�ufer",
						"FZG_Liste_1_falsch",
						"FZG_Liste_0_ori",
						"FZG_Liste_1",
						"FZG_Liste_0",
						"Beleg",
						"Standort_FIBU",
						"Fahrzeugart_neu",
						"Standort",
						SUM("Betrag") OVER (PARTITION BY c142) AS "Summe_Betrag",
						'' AS "Country Code_Kunde",
						"Vat Bus Posting Group_Kunde",
						"FZG_Liste_5_ori",
						"Customer Group Code",
						"FZG_Liste_5",
						CASE 
							WHEN ('' IS NULL)
								THEN (' - ')
							WHEN ('' IN (''))
								THEN (' - ')
							ELSE ('')
							END AS "FZG_Liste_6",
						"Kunde" AS "FZG_Liste_7",
						"FZG_Detail",
						"No_Item",
						"Description_Item",
						"Vehicle Type Code_Item",
						"Modell_zwischen",
						"Vehicle Category Code",
						"Erl�se FZG",
						"Modell_final",
						"Fahrzeugtyp",
						c143 AS c137
					FROM (
						SELECT (((T2."VIN"))) AS c142,
							((T2."VIN")) + T2."Document No_" AS c143,
							CASE 
								WHEN (
										(
											CASE 
												WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
													THEN ('NA')
												WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
													THEN ('GA')
												ELSE NULL
												END
											) = 'GA'
										)
									THEN (T3."Inventory Posting Group")
								ELSE (
										(
											CASE 
												WHEN (
														(
															(
																CASE 
																	WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																		THEN ('NA')
																	WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																		THEN ('GA')
																	ELSE NULL
																	END
																) = 'GA'
															)
														AND (T3."VAT Prod_ Posting Group" LIKE 'DIFF%')
														)
													THEN ('GA - diff.best.')
												WHEN (
														(
															(
																CASE 
																	WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																		THEN ('NA')
																	WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																		THEN ('GA')
																	ELSE NULL
																	END
																) = 'GA'
															)
														AND (NOT T3."VAT Prod_ Posting Group" LIKE 'DIFF%')
														)
													THEN ('GA - regelbest.')
												WHEN (
														(
															(
																CASE 
																	WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																		THEN ('NA')
																	WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																		THEN ('GA')
																	ELSE NULL
																	END
																) = 'NA'
															)
														AND ((left(T3."Inventory Posting Group", 2)) = 'NW')
														)
													THEN ('NA')
												WHEN (
														(
															(
																CASE 
																	WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																		THEN ('NA')
																	WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																		THEN ('GA')
																	ELSE NULL
																	END
																) = 'NA'
															)
														AND ((left(T3."Inventory Posting Group", 2)) = 'FA')
														)
													THEN ('NA')
												WHEN (
														(
															(
																CASE 
																	WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																		THEN ('NA')
																	WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																		THEN ('GA')
																	ELSE NULL
																	END
																) = 'NA'
															)
														AND ((left(T3."Inventory Posting Group", 2)) = 'VF')
														)
													THEN ('VFW')
												ELSE NULL
												END
											)
										)
								END AS "Fahrzeugtyp",
							CASE 
								WHEN (
										NOT (
											CASE 
												WHEN (T3."Make Code" IN ('BMW', 'BMW I', 'BMWI', 'BMW-MINI', 'BMW-MOT'))
													THEN (T3."Make Code")
												ELSE ('Fremdfabrikat')
												END
											) IN ('Fremdfabrikat')
										)
									THEN (
											(
												CASE 
													WHEN (
															(
																(
																	CASE 
																		WHEN (T3."Make Code" IN ('BMW', 'BMW I', 'BMWI', 'BMW-MINI', 'BMW-MOT'))
																			THEN (T3."Make Code")
																		ELSE ('Fremdfabrikat')
																		END
																	) = 'BMW'
																)
															AND ((left(T4."Description", 1)) BETWEEN '1' AND '9')
															)
														THEN ((left(T4."Description", 1)) + 'er')
													WHEN (
															(
																(
																	CASE 
																		WHEN (T3."Make Code" IN ('BMW', 'BMW I', 'BMWI', 'BMW-MINI', 'BMW-MOT'))
																			THEN (T3."Make Code")
																		ELSE ('Fremdfabrikat')
																		END
																	) = 'BMW'
																)
															AND ((left(T4."Description", 1)) BETWEEN 'A' AND 'Z')
															)
														THEN ((left(T4."Description", 2)))
													WHEN (
															(
																(
																	CASE 
																		WHEN (T3."Make Code" IN ('BMW', 'BMW I', 'BMWI', 'BMW-MINI', 'BMW-MOT'))
																			THEN (T3."Make Code")
																		ELSE ('Fremdfabrikat')
																		END
																	) = 'BMW-MINI'
																)
															AND (
																(T4."Description" LIKE '%3-T%')
																OR (T3."Model" LIKE '%3-T%')
																)
															)
														THEN ('3-T�rer')
													WHEN (
															(
																(
																	CASE 
																		WHEN (T3."Make Code" IN ('BMW', 'BMW I', 'BMWI', 'BMW-MINI', 'BMW-MOT'))
																			THEN (T3."Make Code")
																		ELSE ('Fremdfabrikat')
																		END
																	) = 'BMW-MINI'
																)
															AND (
																(T4."Description" LIKE '%5-T%')
																OR (T3."Model" LIKE '%5-T%')
																)
															)
														THEN ('5-T�rer')
													WHEN (
															(
																(
																	CASE 
																		WHEN (T3."Make Code" IN ('BMW', 'BMW I', 'BMWI', 'BMW-MINI', 'BMW-MOT'))
																			THEN (T3."Make Code")
																		ELSE ('Fremdfabrikat')
																		END
																	) = 'BMW-MINI'
																)
															AND (
																(T4."Description" LIKE '%Club%')
																OR (T3."Model" LIKE '%Club%')
																)
															)
														THEN ('Clubman')
													WHEN (
															(
																(
																	CASE 
																		WHEN (T3."Make Code" IN ('BMW', 'BMW I', 'BMWI', 'BMW-MINI', 'BMW-MOT'))
																			THEN (T3."Make Code")
																		ELSE ('Fremdfabrikat')
																		END
																	) = 'BMW-MINI'
																)
															AND (
																(T4."Description" LIKE '%Count%')
																OR (T3."Model" LIKE '%Count%')
																)
															)
														THEN ('Countryman')
													WHEN (
															(
																(
																	CASE 
																		WHEN (T3."Make Code" IN ('BMW', 'BMW I', 'BMWI', 'BMW-MINI', 'BMW-MOT'))
																			THEN (T3."Make Code")
																		ELSE ('Fremdfabrikat')
																		END
																	) = 'BMW-MINI'
																)
															AND (
																(T4."Description" LIKE '%Cou%')
																OR (T3."Model" LIKE '%Cou%')
																)
															)
														THEN ('Coupe')
													WHEN (
															(
																(
																	CASE 
																		WHEN (T3."Make Code" IN ('BMW', 'BMW I', 'BMWI', 'BMW-MINI', 'BMW-MOT'))
																			THEN (T3."Make Code")
																		ELSE ('Fremdfabrikat')
																		END
																	) = 'BMW-MINI'
																)
															AND (
																(T4."Description" LIKE '%Hatch%')
																OR (T3."Model" LIKE '%Hatch%')
																)
															)
														THEN ('Hatch')
													WHEN (
															(
																(
																	CASE 
																		WHEN (T3."Make Code" IN ('BMW', 'BMW I', 'BMWI', 'BMW-MINI', 'BMW-MOT'))
																			THEN (T3."Make Code")
																		ELSE ('Fremdfabrikat')
																		END
																	) = 'BMW-MINI'
																)
															AND (
																(T4."Description" LIKE '%Pace%')
																OR (T3."Model" LIKE '%Pace%')
																)
															)
														THEN ('Paceman')
													WHEN (
															(
																(
																	CASE 
																		WHEN (T3."Make Code" IN ('BMW', 'BMW I', 'BMWI', 'BMW-MINI', 'BMW-MOT'))
																			THEN (T3."Make Code")
																		ELSE ('Fremdfabrikat')
																		END
																	) = 'BMW-MINI'
																)
															AND (
																(T4."Description" LIKE '%Road%')
																OR (T3."Model" LIKE '%Road%')
																)
															)
														THEN ('Roadster')
													WHEN (
															(
																(
																	CASE 
																		WHEN (T3."Make Code" IN ('BMW', 'BMW I', 'BMWI', 'BMW-MINI', 'BMW-MOT'))
																			THEN (T3."Make Code")
																		ELSE ('Fremdfabrikat')
																		END
																	) = 'BMW-MINI'
																)
															AND (
																(T4."Description" LIKE '%Cab%')
																OR (T3."Model" LIKE '%Cab%')
																)
															)
														THEN ('Cabrio')
													ELSE (T4."Description")
													END
												)
											)
								ELSE ('Fremd')
								END AS "Modell_final",
							CASE 
								WHEN ((left(T1."No_", 3)) IN ('882', '884', '887'))
									THEN (0)
								ELSE (
										(
											CASE 
												WHEN (
														(T1."No_" LIKE '8%')
														AND ((right(T2."Global Dimension 1 Code", 2)) IN ('10', '20', '80', '11', '21'))
														)
													THEN (((convert(FLOAT, T2."Amount"))) * - 1)
												ELSE (0)
												END
											)
										)
								END AS "Erl�se FZG",
							T4."Vehicle Category Code" AS "Vehicle Category Code",
							CASE 
								WHEN (
										(
											(
												CASE 
													WHEN (T3."Make Code" IN ('BMW', 'BMW I', 'BMWI', 'BMW-MINI', 'BMW-MOT'))
														THEN (T3."Make Code")
													ELSE ('Fremdfabrikat')
													END
												) = 'BMW'
											)
										AND ((left(T4."Description", 1)) BETWEEN '1' AND '9')
										)
									THEN ((left(T4."Description", 1)) + 'er')
								WHEN (
										(
											(
												CASE 
													WHEN (T3."Make Code" IN ('BMW', 'BMW I', 'BMWI', 'BMW-MINI', 'BMW-MOT'))
														THEN (T3."Make Code")
													ELSE ('Fremdfabrikat')
													END
												) = 'BMW'
											)
										AND ((left(T4."Description", 1)) BETWEEN 'A' AND 'Z')
										)
									THEN ((left(T4."Description", 2)))
								WHEN (
										(
											(
												CASE 
													WHEN (T3."Make Code" IN ('BMW', 'BMW I', 'BMWI', 'BMW-MINI', 'BMW-MOT'))
														THEN (T3."Make Code")
													ELSE ('Fremdfabrikat')
													END
												) = 'BMW-MINI'
											)
										AND (
											(T4."Description" LIKE '%3-T%')
											OR (T3."Model" LIKE '%3-T%')
											)
										)
									THEN ('3-T�rer')
								WHEN (
										(
											(
												CASE 
													WHEN (T3."Make Code" IN ('BMW', 'BMW I', 'BMWI', 'BMW-MINI', 'BMW-MOT'))
														THEN (T3."Make Code")
													ELSE ('Fremdfabrikat')
													END
												) = 'BMW-MINI'
											)
										AND (
											(T4."Description" LIKE '%5-T%')
											OR (T3."Model" LIKE '%5-T%')
											)
										)
									THEN ('5-T�rer')
								WHEN (
										(
											(
												CASE 
													WHEN (T3."Make Code" IN ('BMW', 'BMW I', 'BMWI', 'BMW-MINI', 'BMW-MOT'))
														THEN (T3."Make Code")
													ELSE ('Fremdfabrikat')
													END
												) = 'BMW-MINI'
											)
										AND (
											(T4."Description" LIKE '%Club%')
											OR (T3."Model" LIKE '%Club%')
											)
										)
									THEN ('Clubman')
								WHEN (
										(
											(
												CASE 
													WHEN (T3."Make Code" IN ('BMW', 'BMW I', 'BMWI', 'BMW-MINI', 'BMW-MOT'))
														THEN (T3."Make Code")
													ELSE ('Fremdfabrikat')
													END
												) = 'BMW-MINI'
											)
										AND (
											(T4."Description" LIKE '%Count%')
											OR (T3."Model" LIKE '%Count%')
											)
										)
									THEN ('Countryman')
								WHEN (
										(
											(
												CASE 
													WHEN (T3."Make Code" IN ('BMW', 'BMW I', 'BMWI', 'BMW-MINI', 'BMW-MOT'))
														THEN (T3."Make Code")
													ELSE ('Fremdfabrikat')
													END
												) = 'BMW-MINI'
											)
										AND (
											(T4."Description" LIKE '%Cou%')
											OR (T3."Model" LIKE '%Cou%')
											)
										)
									THEN ('Coupe')
								WHEN (
										(
											(
												CASE 
													WHEN (T3."Make Code" IN ('BMW', 'BMW I', 'BMWI', 'BMW-MINI', 'BMW-MOT'))
														THEN (T3."Make Code")
													ELSE ('Fremdfabrikat')
													END
												) = 'BMW-MINI'
											)
										AND (
											(T4."Description" LIKE '%Hatch%')
											OR (T3."Model" LIKE '%Hatch%')
											)
										)
									THEN ('Hatch')
								WHEN (
										(
											(
												CASE 
													WHEN (T3."Make Code" IN ('BMW', 'BMW I', 'BMWI', 'BMW-MINI', 'BMW-MOT'))
														THEN (T3."Make Code")
													ELSE ('Fremdfabrikat')
													END
												) = 'BMW-MINI'
											)
										AND (
											(T4."Description" LIKE '%Pace%')
											OR (T3."Model" LIKE '%Pace%')
											)
										)
									THEN ('Paceman')
								WHEN (
										(
											(
												CASE 
													WHEN (T3."Make Code" IN ('BMW', 'BMW I', 'BMWI', 'BMW-MINI', 'BMW-MOT'))
														THEN (T3."Make Code")
													ELSE ('Fremdfabrikat')
													END
												) = 'BMW-MINI'
											)
										AND (
											(T4."Description" LIKE '%Road%')
											OR (T3."Model" LIKE '%Road%')
											)
										)
									THEN ('Roadster')
								WHEN (
										(
											(
												CASE 
													WHEN (T3."Make Code" IN ('BMW', 'BMW I', 'BMWI', 'BMW-MINI', 'BMW-MOT'))
														THEN (T3."Make Code")
													ELSE ('Fremdfabrikat')
													END
												) = 'BMW-MINI'
											)
										AND (
											(T4."Description" LIKE '%Cab%')
											OR (T3."Model" LIKE '%Cab%')
											)
										)
									THEN ('Cabrio')
								ELSE (T4."Description")
								END AS "Modell_zwischen",
							T4."Vehicle Type Code" AS "Vehicle Type Code_Item",
							T4."Description" AS "Description_Item",
							T4."No_" AS "No_Item",
							((T2."VIN")) + ' - ' + T3."Location Code" + ' - ' + (
								CASE 
									WHEN (
											(
												CASE 
													WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
														THEN ('NA')
													WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
														THEN ('GA')
													ELSE NULL
													END
												) = 'GA'
											)
										THEN (T3."Inventory Posting Group")
									ELSE (
											(
												CASE 
													WHEN (
															(
																(
																	CASE 
																		WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																			THEN ('NA')
																		WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																			THEN ('GA')
																		ELSE NULL
																		END
																	) = 'GA'
																)
															AND (T3."VAT Prod_ Posting Group" LIKE 'DIFF%')
															)
														THEN ('GA - diff.best.')
													WHEN (
															(
																(
																	CASE 
																		WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																			THEN ('NA')
																		WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																			THEN ('GA')
																		ELSE NULL
																		END
																	) = 'GA'
																)
															AND (NOT T3."VAT Prod_ Posting Group" LIKE 'DIFF%')
															)
														THEN ('GA - regelbest.')
													WHEN (
															(
																(
																	CASE 
																		WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																			THEN ('NA')
																		WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																			THEN ('GA')
																		ELSE NULL
																		END
																	) = 'NA'
																)
															AND ((left(T3."Inventory Posting Group", 2)) = 'NW')
															)
														THEN ('NA')
													WHEN (
															(
																(
																	CASE 
																		WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																			THEN ('NA')
																		WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																			THEN ('GA')
																		ELSE NULL
																		END
																	) = 'NA'
																)
															AND ((left(T3."Inventory Posting Group", 2)) = 'FA')
															)
														THEN ('NA')
													WHEN (
															(
																(
																	CASE 
																		WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																			THEN ('NA')
																		WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																			THEN ('GA')
																		ELSE NULL
																		END
																	) = 'NA'
																)
															AND ((left(T3."Inventory Posting Group", 2)) = 'VF')
															)
														THEN ('VFW')
													ELSE NULL
													END
												)
											)
									END
								) + ' - ' + (
								CASE 
									WHEN (T7."Code" IS NOT NULL)
										THEN (T7."Code" + ' - ' + T7."Name")
									ELSE (T8."Salespers__Purch_ Code")
									END
								) + ' - ' + (T5."No_" + ' - ' + T5."Name") + ' - ' + (
								convert(VARCHAR(50), year((
											CASE 
												WHEN (T3."Date of Sale" IS NULL)
													THEN (T2."Posting Date")
												ELSE (T3."Date of Sale")
												END
											))) + '-' + convert(VARCHAR(50), month((
											CASE 
												WHEN (T3."Date of Sale" IS NULL)
													THEN (T2."Posting Date")
												ELSE (T3."Date of Sale")
												END
											))) + '-' + convert(VARCHAR(50), day((
											CASE 
												WHEN (T3."Date of Sale" IS NULL)
													THEN (T2."Posting Date")
												ELSE (T3."Date of Sale")
												END
											)))
								) AS "FZG_Detail",
							(T5."No_" + ' - ' + T5."Name") AS "Kunde",
							CASE 
								WHEN (T5."Gen_ Bus_ Posting Group" IS NULL)
									THEN (' - ')
								WHEN (T5."Gen_ Bus_ Posting Group" IN (''))
									THEN (' - ')
								ELSE (T5."Gen_ Bus_ Posting Group")
								END AS "FZG_Liste_5",
							T5."Customer Group Code" AS "Customer Group Code",
							CASE 
								WHEN ('' = '')
									THEN (T5."Customer Group Code" + ' / ' + ' - ' + ' / ' + T5."Gen_ Bus_ Posting Group" + ' / ' + (T5."No_" + ' - ' + T5."Name"))
								ELSE (T5."Customer Group Code" + ' / ' + '' + ' / ' + T5."Gen_ Bus_ Posting Group" + ' / ' + (T5."No_" + ' - ' + T5."Name"))
								END AS "FZG_Liste_5_ori",
							T5."VAT Bus_ Posting Group" AS "Vat Bus Posting Group_Kunde",
							CASE 
								WHEN (T3."Location Code" = 'BUR')
									THEN ('10')
								WHEN (T3."Location Code" = 'MUE')
									THEN ('20')
								ELSE ('10')
								END AS "Standort",
							CASE 
								WHEN (
										(
											CASE 
												WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
													THEN ('NA')
												WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
													THEN ('GA')
												ELSE NULL
												END
											) IS NULL
										)
									THEN (
											(
												CASE 
													WHEN ((substring(T1."Global Dimension 1 Code", 3, 2)) = '10')
														THEN ('NA')
													WHEN ((substring(T1."Global Dimension 1 Code", 3, 2)) = '20')
														THEN ('GA')
													WHEN ((substring(T1."Global Dimension 1 Code", 3, 2)) = '80')
														THEN ('NA')
													WHEN ((substring(T1."Global Dimension 1 Code", 3, 2)) = '90')
														THEN ('NA')
													ELSE NULL
													END
												)
											)
								ELSE (
										(
											CASE 
												WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
													THEN ('NA')
												WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
													THEN ('GA')
												ELSE NULL
												END
											)
										)
								END AS "Fahrzeugart_neu",
							(left(T1."Global Dimension 1 Code", 2)) AS "Standort_FIBU",
							T2."Document No_" + ' - ' + T2."Description" + ' - ' + T2."User ID" AS "Beleg",
							CASE 
								WHEN (
										(
											(
												CASE 
													WHEN (((T2."VIN")) = ' ')
														THEN ('Buchungen o. FZG')
													ELSE ('Buchungen m. FZG')
													END
												) = 'Buchungen m. FZG'
											)
										AND (T3."VIN" IS NULL)
										)
									THEN ('sonst. Buchungen m. FZG')
								ELSE (
										(
											CASE 
												WHEN (((T2."VIN")) = ' ')
													THEN ('Buchungen o. FZG')
												ELSE ('Buchungen m. FZG')
												END
											)
										)
								END AS "FZG_Liste_0",
							CASE 
								WHEN (
										(
											CASE 
												WHEN (((T2."VIN")) = ' ')
													THEN ('Buchungen o. FZG')
												ELSE ('Buchungen m. FZG')
												END
											) = 'Buchungen o. FZG'
										)
									THEN (T2."Document No_" + ' - ' + T2."Description")
								ELSE (
										(
											CASE 
												WHEN (
														(
															CASE 
																WHEN (
																		(
																			(
																				CASE 
																					WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																						THEN ('NA')
																					WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																						THEN ('GA')
																					ELSE NULL
																					END
																				) = 'GA'
																			)
																		AND (T3."VAT Prod_ Posting Group" LIKE 'DIFF%')
																		)
																	THEN ('GA - diff.best.')
																WHEN (
																		(
																			(
																				CASE 
																					WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																						THEN ('NA')
																					WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																						THEN ('GA')
																					ELSE NULL
																					END
																				) = 'GA'
																			)
																		AND (NOT T3."VAT Prod_ Posting Group" LIKE 'DIFF%')
																		)
																	THEN ('GA - regelbest.')
																WHEN (
																		(
																			(
																				CASE 
																					WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																						THEN ('NA')
																					WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																						THEN ('GA')
																					ELSE NULL
																					END
																				) = 'NA'
																			)
																		AND ((left(T3."Inventory Posting Group", 2)) = 'NW')
																		)
																	THEN ('NA')
																WHEN (
																		(
																			(
																				CASE 
																					WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																						THEN ('NA')
																					WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																						THEN ('GA')
																					ELSE NULL
																					END
																				) = 'NA'
																			)
																		AND ((left(T3."Inventory Posting Group", 2)) = 'FA')
																		)
																	THEN ('NA')
																WHEN (
																		(
																			(
																				CASE 
																					WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																						THEN ('NA')
																					WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																						THEN ('GA')
																					ELSE NULL
																					END
																				) = 'NA'
																			)
																		AND ((left(T3."Inventory Posting Group", 2)) = 'VF')
																		)
																	THEN ('VFW')
																ELSE NULL
																END
															) IS NOT NULL
														)
													THEN (
															(right(((T2."VIN")), 7)) + ' - ' + (
																CASE 
																	WHEN (
																			(
																				(
																					CASE 
																						WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																							THEN ('NA')
																						WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																							THEN ('GA')
																						ELSE NULL
																						END
																					) = 'GA'
																				)
																			AND (T3."VAT Prod_ Posting Group" LIKE 'DIFF%')
																			)
																		THEN ('GA - diff.best.')
																	WHEN (
																			(
																				(
																					CASE 
																						WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																							THEN ('NA')
																						WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																							THEN ('GA')
																						ELSE NULL
																						END
																					) = 'GA'
																				)
																			AND (NOT T3."VAT Prod_ Posting Group" LIKE 'DIFF%')
																			)
																		THEN ('GA - regelbest.')
																	WHEN (
																			(
																				(
																					CASE 
																						WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																							THEN ('NA')
																						WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																							THEN ('GA')
																						ELSE NULL
																						END
																					) = 'NA'
																				)
																			AND ((left(T3."Inventory Posting Group", 2)) = 'NW')
																			)
																		THEN ('NA')
																	WHEN (
																			(
																				(
																					CASE 
																						WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																							THEN ('NA')
																						WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																							THEN ('GA')
																						ELSE NULL
																						END
																					) = 'NA'
																				)
																			AND ((left(T3."Inventory Posting Group", 2)) = 'FA')
																			)
																		THEN ('NA')
																	WHEN (
																			(
																				(
																					CASE 
																						WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																							THEN ('NA')
																						WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																							THEN ('GA')
																						ELSE NULL
																						END
																					) = 'NA'
																				)
																			AND ((left(T3."Inventory Posting Group", 2)) = 'VF')
																			)
																		THEN ('VFW')
																	ELSE NULL
																	END
																) + ' / ' + (
																convert(VARCHAR(50), year((
																			CASE 
																				WHEN (T3."Date of Sale" IS NULL)
																					THEN (T2."Posting Date")
																				ELSE (T3."Date of Sale")
																				END
																			))) + '-' + convert(VARCHAR(50), month((
																			CASE 
																				WHEN (T3."Date of Sale" IS NULL)
																					THEN (T2."Posting Date")
																				ELSE (T3."Date of Sale")
																				END
																			))) + '-' + convert(VARCHAR(50), day((
																			CASE 
																				WHEN (T3."Date of Sale" IS NULL)
																					THEN (T2."Posting Date")
																				ELSE (T3."Date of Sale")
																				END
																			)))
																)
															)
												ELSE (
														(right(((T2."VIN")))) + ' - ' + (
															convert(VARCHAR(50), year((
																		CASE 
																			WHEN (T3."Date of Sale" IS NULL)
																				THEN (T2."Posting Date")
																			ELSE (T3."Date of Sale")
																			END
																		))) + '-' + convert(VARCHAR(50), month((
																		CASE 
																			WHEN (T3."Date of Sale" IS NULL)
																				THEN (T2."Posting Date")
																			ELSE (T3."Date of Sale")
																			END
																		))) + '-' + convert(VARCHAR(50), day((
																		CASE 
																			WHEN (T3."Date of Sale" IS NULL)
																				THEN (T2."Posting Date")
																			ELSE (T3."Date of Sale")
																			END
																		)))
															)
														)
												END
											)
										)
								END AS "FZG_Liste_1",
							CASE 
								WHEN (((T2."VIN")) = ' ')
									THEN ('Buchungen o. FZG')
								ELSE ('Buchungen m. FZG')
								END AS "FZG_Liste_0_ori",
							CASE 
								WHEN (T1."No_" IN ('78700', '78710', '79000', '79030', '79100', '79130', '88210', '88220', '88230', '88240', '88290', '88310', '88320', '88400', '88410', '88420', '88430', '88560', '88570', '88700', '88710', '88720', '88730', '88740', '88750', '88760', '88770', '88780', '88790'))
									THEN ('Buchungen aus Sonstige Erl�se')
								ELSE (
										(
											CASE 
												WHEN (
														(
															CASE 
																WHEN (
																		(
																			(
																				CASE 
																					WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																						THEN ('NA')
																					WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																						THEN ('GA')
																					ELSE NULL
																					END
																				) = 'GA'
																			)
																		AND (T3."VAT Prod_ Posting Group" LIKE 'DIFF%')
																		)
																	THEN ('GA - diff.best.')
																WHEN (
																		(
																			(
																				CASE 
																					WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																						THEN ('NA')
																					WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																						THEN ('GA')
																					ELSE NULL
																					END
																				) = 'GA'
																			)
																		AND (NOT T3."VAT Prod_ Posting Group" LIKE 'DIFF%')
																		)
																	THEN ('GA - regelbest.')
																WHEN (
																		(
																			(
																				CASE 
																					WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																						THEN ('NA')
																					WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																						THEN ('GA')
																					ELSE NULL
																					END
																				) = 'NA'
																			)
																		AND ((left(T3."Inventory Posting Group", 2)) = 'NW')
																		)
																	THEN ('NA')
																WHEN (
																		(
																			(
																				CASE 
																					WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																						THEN ('NA')
																					WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																						THEN ('GA')
																					ELSE NULL
																					END
																				) = 'NA'
																			)
																		AND ((left(T3."Inventory Posting Group", 2)) = 'FA')
																		)
																	THEN ('NA')
																WHEN (
																		(
																			(
																				CASE 
																					WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																						THEN ('NA')
																					WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																						THEN ('GA')
																					ELSE NULL
																					END
																				) = 'NA'
																			)
																		AND ((left(T3."Inventory Posting Group", 2)) = 'VF')
																		)
																	THEN ('VFW')
																ELSE NULL
																END
															) IS NOT NULL
														)
													THEN (
															(right(((T2."VIN")), 7)) + ' - ' + (
																CASE 
																	WHEN (
																			(
																				(
																					CASE 
																						WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																							THEN ('NA')
																						WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																							THEN ('GA')
																						ELSE NULL
																						END
																					) = 'GA'
																				)
																			AND (T3."VAT Prod_ Posting Group" LIKE 'DIFF%')
																			)
																		THEN ('GA - diff.best.')
																	WHEN (
																			(
																				(
																					CASE 
																						WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																							THEN ('NA')
																						WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																							THEN ('GA')
																						ELSE NULL
																						END
																					) = 'GA'
																				)
																			AND (NOT T3."VAT Prod_ Posting Group" LIKE 'DIFF%')
																			)
																		THEN ('GA - regelbest.')
																	WHEN (
																			(
																				(
																					CASE 
																						WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																							THEN ('NA')
																						WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																							THEN ('GA')
																						ELSE NULL
																						END
																					) = 'NA'
																				)
																			AND ((left(T3."Inventory Posting Group", 2)) = 'NW')
																			)
																		THEN ('NA')
																	WHEN (
																			(
																				(
																					CASE 
																						WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																							THEN ('NA')
																						WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																							THEN ('GA')
																						ELSE NULL
																						END
																					) = 'NA'
																				)
																			AND ((left(T3."Inventory Posting Group", 2)) = 'FA')
																			)
																		THEN ('NA')
																	WHEN (
																			(
																				(
																					CASE 
																						WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																							THEN ('NA')
																						WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																							THEN ('GA')
																						ELSE NULL
																						END
																					) = 'NA'
																				)
																			AND ((left(T3."Inventory Posting Group", 2)) = 'VF')
																			)
																		THEN ('VFW')
																	ELSE NULL
																	END
																) + ' / ' + (
																convert(VARCHAR(50), year((
																			CASE 
																				WHEN (T3."Date of Sale" IS NULL)
																					THEN (T2."Posting Date")
																				ELSE (T3."Date of Sale")
																				END
																			))) + '-' + convert(VARCHAR(50), month((
																			CASE 
																				WHEN (T3."Date of Sale" IS NULL)
																					THEN (T2."Posting Date")
																				ELSE (T3."Date of Sale")
																				END
																			))) + '-' + convert(VARCHAR(50), day((
																			CASE 
																				WHEN (T3."Date of Sale" IS NULL)
																					THEN (T2."Posting Date")
																				ELSE (T3."Date of Sale")
																				END
																			)))
																)
															)
												ELSE (
														(right(((T2."VIN")))) + ' - ' + (
															convert(VARCHAR(50), year((
																		CASE 
																			WHEN (T3."Date of Sale" IS NULL)
																				THEN (T2."Posting Date")
																			ELSE (T3."Date of Sale")
																			END
																		))) + '-' + convert(VARCHAR(50), month((
																		CASE 
																			WHEN (T3."Date of Sale" IS NULL)
																				THEN (T2."Posting Date")
																			ELSE (T3."Date of Sale")
																			END
																		))) + '-' + convert(VARCHAR(50), day((
																		CASE 
																			WHEN (T3."Date of Sale" IS NULL)
																				THEN (T2."Posting Date")
																			ELSE (T3."Date of Sale")
																			END
																		)))
															)
														)
												END
											)
										)
								END AS "FZG_Liste_1_falsch",
							CASE 
								WHEN (T7."Code" IS NOT NULL)
									THEN (T7."Code" + ' - ' + T7."Name")
								ELSE (T8."Salespers__Purch_ Code")
								END AS "Verk�ufer",
							T7."Name" AS "Name_f�r_VEH_Ledger_Entry",
							T7."Code" AS "Code_f�r_VEH_Ledger_Entry",
							T8."Salespers__Purch_ Code" AS "Salespers Purch Code_VLE",
							CASE 
								WHEN ((substring(T1."Global Dimension 1 Code", 3, 2)) = '10')
									THEN ('NA')
								WHEN ((substring(T1."Global Dimension 1 Code", 3, 2)) = '20')
									THEN ('GA')
								WHEN ((substring(T1."Global Dimension 1 Code", 3, 2)) = '80')
									THEN ('NA')
								WHEN ((substring(T1."Global Dimension 1 Code", 3, 2)) = '90')
									THEN ('NA')
								ELSE NULL
								END AS "Fahrzeugart_Schmidt",
							((T2."VIN")) + (convert(VARCHAR(50), year(T2."Posting Date")) + '-' + convert(VARCHAR(50), month(T2."Posting Date")) + '-' + convert(VARCHAR(50), day(T2."Posting Date"))) AS "VIN + PostingDate",
							CASE 
								WHEN (
										(T2."Book No_" = T3."Current Book No_")
										AND (
											(
												CASE 
													WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
														THEN ('NA')
													WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
														THEN ('GA')
													ELSE NULL
													END
												) = 'GA'
											)
										)
									THEN ('ja')
								WHEN (
										(T2."Book No_" <> T3."Current Book No_")
										AND (
											(
												CASE 
													WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
														THEN ('NA')
													WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
														THEN ('GA')
													ELSE NULL
													END
												) = 'GA'
											)
										)
									THEN ('nein')
								ELSE NULL
								END AS "Buchnummer gleich_ja_nein",
							CASE 
								WHEN (T3."Make Code" IN ('BMW', 'BMW I', 'BMWI', 'BMW-MINI', 'BMW-MOT'))
									THEN (T3."Make Code")
								ELSE ('Fremdfabrikat')
								END AS "Fabrikat",
							T3."Current Book No_" AS "Current Book No",
							T3."Current Branch Book No_" AS "Current Branch Book No",
							CASE 
								WHEN (T1."No_" LIKE '4%')
									THEN (((convert(FLOAT, T2."Amount"))))
								ELSE (0)
								END AS "int. Kosten",
							CASE 
								WHEN (T1."No_" BETWEEN '71400' AND '71690')
									THEN (((convert(FLOAT, T2."Amount"))) * - 1)
								ELSE (0)
								END AS "Bonus",
							CASE 
								WHEN (
										(
											(T1."No_" BETWEEN '71000' AND '71390')
											OR (T1."No_" BETWEEN '71700' AND '72995')
											)
										OR (T1."No_" IN ('78200', '78700', '78710', '79000', '79030', '79100', '79130', '78580'))
										)
									THEN (((convert(FLOAT, T2."Amount"))))
								ELSE (0)
								END AS "EK Fahrzeug",
							(
								CASE 
									WHEN (
											(
												(T1."No_" BETWEEN '71000' AND '71390')
												OR (T1."No_" BETWEEN '71700' AND '72995')
												)
											OR (T1."No_" IN ('78200', '78700', '78710', '79000', '79030', '79100', '79130', '78580'))
											)
										THEN (((convert(FLOAT, T2."Amount"))))
									ELSE (0)
									END
								) - (
								CASE 
									WHEN (T1."No_" BETWEEN '71400' AND '71690')
										THEN (((convert(FLOAT, T2."Amount"))) * - 1)
									ELSE (0)
									END
								) AS "Einsatz",
							CASE 
								WHEN (
										(T1."No_" LIKE '8%')
										AND ((right(T2."Global Dimension 1 Code", 2)) IN ('10', '20', '80', '11', '21'))
										)
									THEN (((convert(FLOAT, T2."Amount"))) * - 1)
								ELSE (0)
								END AS "Erl�s",
							CASE 
								WHEN (
										(
											CASE 
												WHEN (T7."Code" IS NOT NULL)
													THEN (T7."Code" + ' - ' + T7."Name")
												ELSE (T8."Salespers__Purch_ Code")
												END
											) IS NULL
										)
									THEN (' - ' + ' / ' + (T5."No_" + ' - ' + T5."Name"))
								ELSE (
										(
											CASE 
												WHEN (T7."Code" IS NOT NULL)
													THEN (T7."Code" + ' - ' + T7."Name")
												ELSE (T8."Salespers__Purch_ Code")
												END
											) + ' / ' + (T5."No_" + ' - ' + T5."Name")
										)
								END AS "FZG_Liste_4",
							T3."Model" AS "Model_ori",
							CASE 
								WHEN ('' IS NULL)
									THEN (' - ' + ' / ' + T6."Name")
								ELSE ('' + ' / ' + T6."Name")
								END AS "FZG_Liste_2",
							CASE 
								WHEN (
										(
											CASE 
												WHEN (
														(
															(
																CASE 
																	WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																		THEN ('NA')
																	WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																		THEN ('GA')
																	ELSE NULL
																	END
																) = 'GA'
															)
														AND (T3."VAT Prod_ Posting Group" LIKE 'DIFF%')
														)
													THEN ('GA - diff.best.')
												WHEN (
														(
															(
																CASE 
																	WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																		THEN ('NA')
																	WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																		THEN ('GA')
																	ELSE NULL
																	END
																) = 'GA'
															)
														AND (NOT T3."VAT Prod_ Posting Group" LIKE 'DIFF%')
														)
													THEN ('GA - regelbest.')
												WHEN (
														(
															(
																CASE 
																	WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																		THEN ('NA')
																	WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																		THEN ('GA')
																	ELSE NULL
																	END
																) = 'NA'
															)
														AND ((left(T3."Inventory Posting Group", 2)) = 'NW')
														)
													THEN ('NA')
												WHEN (
														(
															(
																CASE 
																	WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																		THEN ('NA')
																	WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																		THEN ('GA')
																	ELSE NULL
																	END
																) = 'NA'
															)
														AND ((left(T3."Inventory Posting Group", 2)) = 'FA')
														)
													THEN ('NA')
												WHEN (
														(
															(
																CASE 
																	WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																		THEN ('NA')
																	WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																		THEN ('GA')
																	ELSE NULL
																	END
																) = 'NA'
															)
														AND ((left(T3."Inventory Posting Group", 2)) = 'VF')
														)
													THEN ('VFW')
												ELSE NULL
												END
											) IS NOT NULL
										)
									THEN (
											(right(((T2."VIN")), 7)) + ' - ' + (
												CASE 
													WHEN (
															(
																(
																	CASE 
																		WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																			THEN ('NA')
																		WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																			THEN ('GA')
																		ELSE NULL
																		END
																	) = 'GA'
																)
															AND (T3."VAT Prod_ Posting Group" LIKE 'DIFF%')
															)
														THEN ('GA - diff.best.')
													WHEN (
															(
																(
																	CASE 
																		WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																			THEN ('NA')
																		WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																			THEN ('GA')
																		ELSE NULL
																		END
																	) = 'GA'
																)
															AND (NOT T3."VAT Prod_ Posting Group" LIKE 'DIFF%')
															)
														THEN ('GA - regelbest.')
													WHEN (
															(
																(
																	CASE 
																		WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																			THEN ('NA')
																		WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																			THEN ('GA')
																		ELSE NULL
																		END
																	) = 'NA'
																)
															AND ((left(T3."Inventory Posting Group", 2)) = 'NW')
															)
														THEN ('NA')
													WHEN (
															(
																(
																	CASE 
																		WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																			THEN ('NA')
																		WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																			THEN ('GA')
																		ELSE NULL
																		END
																	) = 'NA'
																)
															AND ((left(T3."Inventory Posting Group", 2)) = 'FA')
															)
														THEN ('NA')
													WHEN (
															(
																(
																	CASE 
																		WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																			THEN ('NA')
																		WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																			THEN ('GA')
																		ELSE NULL
																		END
																	) = 'NA'
																)
															AND ((left(T3."Inventory Posting Group", 2)) = 'VF')
															)
														THEN ('VFW')
													ELSE NULL
													END
												) + ' / ' + (
												convert(VARCHAR(50), year((
															CASE 
																WHEN (T3."Date of Sale" IS NULL)
																	THEN (T2."Posting Date")
																ELSE (T3."Date of Sale")
																END
															))) + '-' + convert(VARCHAR(50), month((
															CASE 
																WHEN (T3."Date of Sale" IS NULL)
																	THEN (T2."Posting Date")
																ELSE (T3."Date of Sale")
																END
															))) + '-' + convert(VARCHAR(50), day((
															CASE 
																WHEN (T3."Date of Sale" IS NULL)
																	THEN (T2."Posting Date")
																ELSE (T3."Date of Sale")
																END
															)))
												)
											)
								ELSE (
										(right(((T2."VIN")))) + ' - ' + (
											convert(VARCHAR(50), year((
														CASE 
															WHEN (T3."Date of Sale" IS NULL)
																THEN (T2."Posting Date")
															ELSE (T3."Date of Sale")
															END
														))) + '-' + convert(VARCHAR(50), month((
														CASE 
															WHEN (T3."Date of Sale" IS NULL)
																THEN (T2."Posting Date")
															ELSE (T3."Date of Sale")
															END
														))) + '-' + convert(VARCHAR(50), day((
														CASE 
															WHEN (T3."Date of Sale" IS NULL)
																THEN (T2."Posting Date")
															ELSE (T3."Date of Sale")
															END
														)))
											)
										)
								END AS "FZG_Liste_1_ori",
							T3."Engine Code" AS "Engine Code",
							T6."Name" AS "Name_Vorbesitzer",
							T6."No_" AS "No_Vorbesitzer",
							T3."Old Customer No_" AS "Old Customer No_2",
							T5."Gen_ Bus_ Posting Group" AS "Kundenart",
							T5."Customer Type" AS "Customer Type",
							T5."Name" AS "Name_Customer",
							T5."No_" AS "No_Customer",
							T3."Customer No_" AS "Customer No",
							CASE 
								WHEN (T3."Date of Sale" IS NULL)
									THEN (T2."Posting Date")
								ELSE (T3."Date of Sale")
								END AS "Invoice Date",
							T3."Date of Sale" AS "Date Of Sale",
							T3."Inventory Posting Group" AS "Inventory Posting Group",
							(right(((T2."VIN")), 7)) AS "FZG-Liste",
							((convert(FLOAT, T2."Amount"))) AS "Betrag",
							CASE 
								WHEN (
										(
											CASE 
												WHEN (
														(
															(
																CASE 
																	WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																		THEN ('NA')
																	WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																		THEN ('GA')
																	ELSE NULL
																	END
																) = 'GA'
															)
														AND (T3."VAT Prod_ Posting Group" LIKE 'DIFF%')
														)
													THEN ('GA - diff.best.')
												WHEN (
														(
															(
																CASE 
																	WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																		THEN ('NA')
																	WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																		THEN ('GA')
																	ELSE NULL
																	END
																) = 'GA'
															)
														AND (NOT T3."VAT Prod_ Posting Group" LIKE 'DIFF%')
														)
													THEN ('GA - regelbest.')
												WHEN (
														(
															(
																CASE 
																	WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																		THEN ('NA')
																	WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																		THEN ('GA')
																	ELSE NULL
																	END
																) = 'NA'
															)
														AND ((left(T3."Inventory Posting Group", 2)) = 'NW')
														)
													THEN ('NA')
												WHEN (
														(
															(
																CASE 
																	WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																		THEN ('NA')
																	WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																		THEN ('GA')
																	ELSE NULL
																	END
																) = 'NA'
															)
														AND ((left(T3."Inventory Posting Group", 2)) = 'FA')
														)
													THEN ('NA')
												WHEN (
														(
															(
																CASE 
																	WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																		THEN ('NA')
																	WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																		THEN ('GA')
																	ELSE NULL
																	END
																) = 'NA'
															)
														AND ((left(T3."Inventory Posting Group", 2)) = 'VF')
														)
													THEN ('VFW')
												ELSE NULL
												END
											) = 'VFW'
										)
									THEN ((convert(VARCHAR(50), year(T3."Initial Registration")) + '-' + convert(VARCHAR(50), month(T3."Initial Registration")) + '-' + convert(VARCHAR(50), day(T3."Initial Registration"))))
								WHEN (
										(
											CASE 
												WHEN (
														(
															(
																CASE 
																	WHEN ((left(T3."Inventory Posting Group")) IN ('NW', 'VF', 'FA'))
																		THEN ('NA')
																	WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																		THEN ('GA')
																	ELSE NULL
																	END
																) = 'GA'
															)
														AND (T3."VAT Prod_ Posting Group" LIKE 'DIFF%')
														)
													THEN ('GA - diff.best.')
												WHEN (
														(
															(
																CASE 
																	WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																		THEN ('NA')
																	WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																		THEN ('GA')
																	ELSE NULL
																	END
																) = 'GA'
															)
														AND (NOT T3."VAT Prod_ Posting Group" LIKE 'DIFF%')
														)
													THEN ('GA - regelbest.')
												WHEN (
														(
															(
																CASE 
																	WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																		THEN ('NA')
																	WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																		THEN ('GA')
																	ELSE NULL
																	END
																) = 'NA'
															)
														AND ((left(T3."Inventory Posting Group", 2)) = 'NW')
														)
													THEN ('NA')
												WHEN (
														(
															(
																CASE 
																	WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																		THEN ('NA')
																	WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																		THEN ('GA')
																	ELSE NULL
																	END
																) = 'NA'
															)
														AND ((left(T3."Inventory Posting Group", 2)) = 'FA')
														)
													THEN ('NA')
												WHEN (
														(
															(
																CASE 
																	WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																		THEN ('NA')
																	WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																		THEN ('GA')
																	ELSE NULL
																	END
																) = 'NA'
															)
														AND ((left(T3."Inventory Posting Group", 2)) = 'VF')
														)
													THEN ('VFW')
												ELSE NULL
												END
											) = 'NA'
										)
									THEN ((convert(VARCHAR(50), year(T3."Purchase Receipt Date")) + '-' + convert(VARCHAR(50), month(T3."Purchase Receipt Date")) + '-' + convert(VARCHAR(50), day(T3."Purchase Receipt Date"))))
								WHEN (
										(
											CASE 
												WHEN ((left(T3."Inventory Posting Group")) IN ('NW', 'VF', 'FA'))
													THEN ('NA')
												WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
													THEN ('GA')
												ELSE NULL
												END
											) = 'GA'
										)
									THEN ((convert(VARCHAR(50), year(T3."Purchase Receipt Date")) + '-' + convert(VARCHAR(50), month(T3."Purchase Receipt Date")) + '-' + convert(VARCHAR(50), day(T3."Purchase Receipt Date"))))
								ELSE NULL
								END AS "EZ/Eingang",
							T3."Initial Registration" AS "Initial Registration",
							CASE 
								WHEN (
										(
											(
												CASE 
													WHEN (
															(
																(
																	CASE 
																		WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																			THEN ('NA')
																		WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																			THEN ('GA')
																		ELSE NULL
																		END
																	) = 'GA'
																)
															AND (T3."VAT Prod_ Posting Group" LIKE 'DIFF%')
															)
														THEN ('GA - diff.best.')
													WHEN (
															(
																(
																	CASE 
																		WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																			THEN ('NA')
																		WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																			THEN ('GA')
																		ELSE NULL
																		END
																	) = 'GA'
																)
															AND (NOT T3."VAT Prod_ Posting Group" LIKE 'DIFF%')
															)
														THEN ('GA - regelbest.')
													WHEN (
															(
																(
																	CASE 
																		WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																			THEN ('NA')
																		WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																			THEN ('GA')
																		ELSE NULL
																		END
																	) = 'NA'
																)
															AND ((left(T3."Inventory Posting Group", 2)) = 'NW')
															)
														THEN ('NA')
													WHEN (
															(
																(
																	CASE 
																		WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																			THEN ('NA')
																		WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																			THEN ('GA')
																		ELSE NULL
																		END
																	) = 'NA'
																)
															AND ((left(T3."Inventory Posting Group", 2)) = 'FA')
															)
														THEN ('NA')
													WHEN (
															(
																(
																	CASE 
																		WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																			THEN ('NA')
																		WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																			THEN ('GA')
																		ELSE NULL
																		END
																	) = 'NA'
																)
															AND ((left(T3."Inventory Posting Group", 2)) = 'VF')
															)
														THEN ('VFW')
													ELSE NULL
													END
												) = 'NA'
											)
										AND (
											(
												(
													- 1 * datediff(day, (
															CASE 
																WHEN (T3."Date of Sale" IS NULL)
																	THEN (T2."Posting Date")
																ELSE (T3."Date of Sale")
																END
															), T3."Purchase Receipt Date")
													)
												) BETWEEN 0 AND 30
											)
										)
									THEN ('0 - 30 Tage')
								WHEN (
										(
											(
												CASE 
													WHEN (
															(
																(
																	CASE 
																		WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																			THEN ('NA')
																		WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																			THEN ('GA')
																		ELSE NULL
																		END
																	) = 'GA'
																)
															AND (T3."VAT Prod_ Posting Group" LIKE 'DIFF%')
															)
														THEN ('GA - diff.best.')
													WHEN (
															(
																(
																	CASE 
																		WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																			THEN ('NA')
																		WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																			THEN ('GA')
																		ELSE NULL
																		END
																	) = 'GA'
																)
															AND (NOT T3."VAT Prod_ Posting Group" LIKE 'DIFF%')
															)
														THEN ('GA - regelbest.')
													WHEN (
															(
																(
																	CASE 
																		WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																			THEN ('NA')
																		WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																			THEN ('GA')
																		ELSE NULL
																		END
																	) = 'NA'
																)
															AND ((left(T3."Inventory Posting Group", 2)) = 'NW')
															)
														THEN ('NA')
													WHEN (
															(
																(
																	CASE 
																		WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																			THEN ('NA')
																		WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																			THEN ('GA')
																		ELSE NULL
																		END
																	) = 'NA'
																)
															AND ((left(T3."Inventory Posting Group", 2)) = 'FA')
															)
														THEN ('NA')
													WHEN (
															(
																(
																	CASE 
																		WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																			THEN ('NA')
																		WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																			THEN ('GA')
																		ELSE NULL
																		END
																	) = 'NA'
																)
															AND ((left(T3."Inventory Posting Group", 2)) = 'VF')
															)
														THEN ('VFW')
													ELSE NULL
													END
												) = 'NA'
											)
										AND (
											(
												(
													- 1 * datediff(day, (
															CASE 
																WHEN (T3."Date of Sale" IS NULL)
																	THEN (T2."Posting Date")
																ELSE (T3."Date of Sale")
																END
															), T3."Purchase Receipt Date")
													)
												) BETWEEN 31 AND 60
											)
										)
									THEN ('31 - 60 Tage')
								WHEN (
										(
											(
												CASE 
													WHEN (
															(
																(
																	CASE 
																		WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																			THEN ('NA')
																		WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																			THEN ('GA')
																		ELSE NULL
																		END
																	) = 'GA'
																)
															AND (T3."VAT Prod_ Posting Group" LIKE 'DIFF%')
															)
														THEN ('GA - diff.best.')
													WHEN (
															(
																(
																	CASE 
																		WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																			THEN ('NA')
																		WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																			THEN ('GA')
																		ELSE NULL
																		END
																	) = 'GA'
																)
															AND (NOT T3."VAT Prod_ Posting Group" LIKE 'DIFF%')
															)
														THEN ('GA - regelbest.')
													WHEN (
															(
																(
																	CASE 
																		WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																			THEN ('NA')
																		WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																			THEN ('GA')
																		ELSE NULL
																		END
																	) = 'NA'
																)
															AND ((left(T3."Inventory Posting Group", 2)) = 'NW')
															)
														THEN ('NA')
													WHEN (
															(
																(
																	CASE 
																		WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																			THEN ('NA')
																		WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																			THEN ('GA')
																		ELSE NULL
																		END
																	) = 'NA'
																)
															AND ((left(T3."Inventory Posting Group", 2)) = 'FA')
															)
														THEN ('NA')
													WHEN (
															(
																(
																	CASE 
																		WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																			THEN ('NA')
																		WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																			THEN ('GA')
																		ELSE NULL
																		END
																	) = 'NA'
																)
															AND ((left(T3."Inventory Posting Group", 2)) = 'VF')
															)
														THEN ('VFW')
													ELSE NULL
													END
												) = 'NA'
											)
										AND (
											(
												(
													- 1 * datediff(day, (
															CASE 
																WHEN (T3."Date of Sale" IS NULL)
																	THEN (T2."Posting Date")
																ELSE (T3."Date of Sale")
																END
															), T3."Purchase Receipt Date")
													)
												) BETWEEN 61 AND 90
											)
										)
									THEN ('61 - 90 Tage')
								WHEN (
										(
											(
												CASE 
													WHEN (
															(
																(
																	CASE 
																		WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																			THEN ('NA')
																		WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																			THEN ('GA')
																		ELSE NULL
																		END
																	) = 'GA'
																)
															AND (T3."VAT Prod_ Posting Group" LIKE 'DIFF%')
															)
														THEN ('GA - diff.best.')
													WHEN (
															(
																(
																	CASE 
																		WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																			THEN ('NA')
																		WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																			THEN ('GA')
																		ELSE NULL
																		END
																	) = 'GA'
																)
															AND (NOT T3."VAT Prod_ Posting Group" LIKE 'DIFF%')
															)
														THEN ('GA - regelbest.')
													WHEN (
															(
																(
																	CASE 
																		WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																			THEN ('NA')
																		WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																			THEN ('GA')
																		ELSE NULL
																		END
																	) = 'NA'
																)
															AND ((left(T3."Inventory Posting Group", 2)) = 'NW')
															)
														THEN ('NA')
													WHEN (
															(
																(
																	CASE 
																		WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																			THEN ('NA')
																		WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																			THEN ('GA')
																		ELSE NULL
																		END
																	) = 'NA'
																)
															AND ((left(T3."Inventory Posting Group", 2)) = 'FA')
															)
														THEN ('NA')
													WHEN (
															(
																(
																	CASE 
																		WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																			THEN ('NA')
																		WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																			THEN ('GA')
																		ELSE NULL
																		END
																	) = 'NA'
																)
															AND ((left(T3."Inventory Posting Group", 2)) = 'VF')
															)
														THEN ('VFW')
													ELSE NULL
													END
												) = 'NA'
											)
										AND (
											(
												(
													- 1 * datediff(day, (
															CASE 
																WHEN (T3."Date of Sale" IS NULL)
																	THEN (T2."Posting Date")
																ELSE (T3."Date of Sale")
																END
															), T3."Purchase Receipt Date")
													)
												) BETWEEN 91 AND 180
											)
										)
									THEN ('91 - 180 Tage')
								WHEN (
										(
											(
												CASE 
													WHEN (
															(
																(
																	CASE 
																		WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																			THEN ('NA')
																		WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																			THEN ('GA')
																		ELSE NULL
																		END
																	) = 'GA'
																)
															AND (T3."VAT Prod_ Posting Group" LIKE 'DIFF%')
															)
														THEN ('GA - diff.best.')
													WHEN (
															(
																(
																	CASE 
																		WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																			THEN ('NA')
																		WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																			THEN ('GA')
																		ELSE NULL
																		END
																	) = 'GA'
																)
															AND (NOT T3."VAT Prod_ Posting Group" LIKE 'DIFF%')
															)
														THEN ('GA - regelbest.')
													WHEN (
															(
																(
																	CASE 
																		WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																			THEN ('NA')
																		WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																			THEN ('GA')
																		ELSE NULL
																		END
																	) = 'NA'
																)
															AND ((left(T3."Inventory Posting Group", 2)) = 'NW')
															)
														THEN ('NA')
													WHEN (
															(
																(
																	CASE 
																		WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																			THEN ('NA')
																		WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																			THEN ('GA')
																		ELSE NULL
																		END
																	) = 'NA'
																)
															AND ((left(T3."Inventory Posting Group", 2)) = 'FA')
															)
														THEN ('NA')
													WHEN (
															(
																(
																	CASE 
																		WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																			THEN ('NA')
																		WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																			THEN ('GA')
																		ELSE NULL
																		END
																	) = 'NA'
																)
															AND ((left(T3."Inventory Posting Group", 2)) = 'VF')
															)
														THEN ('VFW')
													ELSE NULL
													END
												) = 'NA'
											)
										AND (
											(
												(
													- 1 * datediff(day, (
															CASE 
																WHEN (T3."Date of Sale" IS NULL)
																	THEN (T2."Posting Date")
																ELSE (T3."Date of Sale")
																END
															), T3."Purchase Receipt Date")
													)
												) > 180
											)
										)
									THEN ('> 180 Tage')
								WHEN (
										(
											(
												CASE 
													WHEN (
															(
																(
																	CASE 
																		WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																			THEN ('NA')
																		WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																			THEN ('GA')
																		ELSE NULL
																		END
																	) = 'GA'
																)
															AND (T3."VAT Prod_ Posting Group" LIKE 'DIFF%')
															)
														THEN ('GA - diff.best.')
													WHEN (
															(
																(
																	CASE 
																		WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																			THEN ('NA')
																		WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																			THEN ('GA')
																		ELSE NULL
																		END
																	) = 'GA'
																)
															AND (NOT T3."VAT Prod_ Posting Group" LIKE 'DIFF%')
															)
														THEN ('GA - regelbest.')
													WHEN (
															(
																(
																	CASE 
																		WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																			THEN ('NA')
																		WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																			THEN ('GA')
																		ELSE NULL
																		END
																	) = 'NA'
																)
															AND ((left(T3."Inventory Posting Group", 2)) = 'NW')
															)
														THEN ('NA')
													WHEN (
															(
																(
																	CASE 
																		WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																			THEN ('NA')
																		WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																			THEN ('GA')
																		ELSE NULL
																		END
																	) = 'NA'
																)
															AND ((left(T3."Inventory Posting Group", 2)) = 'FA')
															)
														THEN ('NA')
													WHEN (
															(
																(
																	CASE 
																		WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																			THEN ('NA')
																		WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																			THEN ('GA')
																		ELSE NULL
																		END
																	) = 'NA'
																)
															AND ((left(T3."Inventory Posting Group", 2)) = 'VF')
															)
														THEN ('VFW')
													ELSE NULL
													END
												) = 'VFW'
											)
										AND (
											(
												(
													- 1 * datediff(day, (
															CASE 
																WHEN (T3."Date of Sale" IS NULL)
																	THEN (T2."Posting Date")
																ELSE (T3."Date of Sale")
																END
															), T3."Purchase Receipt Date")
													)
												) BETWEEN 0 AND 90
											)
										)
									THEN ('0 - 90 Tage')
								WHEN (
										(
											(
												CASE 
													WHEN (
															(
																(
																	CASE 
																		WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																			THEN ('NA')
																		WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																			THEN ('GA')
																		ELSE NULL
																		END
																	) = 'GA'
																)
															AND (T3."VAT Prod_ Posting Group" LIKE 'DIFF%')
															)
														THEN ('GA - diff.best.')
													WHEN (
															(
																(
																	CASE 
																		WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																			THEN ('NA')
																		WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																			THEN ('GA')
																		ELSE NULL
																		END
																	) = 'GA'
																)
															AND (NOT T3."VAT Prod_ Posting Group" LIKE 'DIFF%')
															)
														THEN ('GA - regelbest.')
													WHEN (
															(
																(
																	CASE 
																		WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																			THEN ('NA')
																		WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																			THEN ('GA')
																		ELSE NULL
																		END
																	) = 'NA'
																)
															AND ((left(T3."Inventory Posting Group", 2)) = 'NW')
															)
														THEN ('NA')
													WHEN (
															(
																(
																	CASE 
																		WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																			THEN ('NA')
																		WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																			THEN ('GA')
																		ELSE NULL
																		END
																	) = 'NA'
																)
															AND ((left(T3."Inventory Posting Group", 2)) = 'FA')
															)
														THEN ('NA')
													WHEN (
															(
																(
																	CASE 
																		WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																			THEN ('NA')
																		WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																			THEN ('GA')
																		ELSE NULL
																		END
																	) = 'NA'
																)
															AND ((left(T3."Inventory Posting Group", 2)) = 'VF')
															)
														THEN ('VFW')
													ELSE NULL
													END
												) = 'VFW'
											)
										AND (
											(
												(
													- 1 * datediff(day, (
															CASE 
																WHEN (T3."Date of Sale" IS NULL)
																	THEN (T2."Posting Date")
																ELSE (T3."Date of Sale")
																END
															), T3."Purchase Receipt Date")
													)
												) BETWEEN 91 AND 150
											)
										)
									THEN ('91 - 150 Tage')
								WHEN (
										(
											(
												CASE 
													WHEN (
															(
																(
																	CASE 
																		WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																			THEN ('NA')
																		WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																			THEN ('GA')
																		ELSE NULL
																		END
																	) = 'GA'
																)
															AND (T3."VAT Prod_ Posting Group" LIKE 'DIFF%')
															)
														THEN ('GA - diff.best.')
													WHEN (
															(
																(
																	CASE 
																		WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																			THEN ('NA')
																		WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																			THEN ('GA')
																		ELSE NULL
																		END
																	) = 'GA'
																)
															AND (NOT T3."VAT Prod_ Posting Group" LIKE 'DIFF%')
															)
														THEN ('GA - regelbest.')
													WHEN (
															(
																(
																	CASE 
																		WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																			THEN ('NA')
																		WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																			THEN ('GA')
																		ELSE NULL
																		END
																	) = 'NA'
																)
															AND ((left(T3."Inventory Posting Group", 2)) = 'NW')
															)
														THEN ('NA')
													WHEN (
															(
																(
																	CASE 
																		WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																			THEN ('NA')
																		WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																			THEN ('GA')
																		ELSE NULL
																		END
																	) = 'NA'
																)
															AND ((left(T3."Inventory Posting Group", 2)) = 'FA')
															)
														THEN ('NA')
													WHEN (
															(
																(
																	CASE 
																		WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																			THEN ('NA')
																		WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																			THEN ('GA')
																		ELSE NULL
																		END
																	) = 'NA'
																)
															AND ((left(T3."Inventory Posting Group", 2)) = 'VF')
															)
														THEN ('VFW')
													ELSE NULL
													END
												) = 'VFW'
											)
										AND (
											(
												(
													- 1 * datediff(day, (
															CASE 
																WHEN (T3."Date of Sale" IS NULL)
																	THEN (T2."Posting Date")
																ELSE (T3."Date of Sale")
																END
															), T3."Purchase Receipt Date")
													)
												) BETWEEN 151 AND 210
											)
										)
									THEN ('151 - 210 Tage')
								WHEN (
										(
											(
												CASE 
													WHEN (
															(
																(
																	CASE 
																		WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																			THEN ('NA')
																		WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																			THEN ('GA')
																		ELSE NULL
																		END
																	) = 'GA'
																)
															AND (T3."VAT Prod_ Posting Group" LIKE 'DIFF%')
															)
														THEN ('GA - diff.best.')
													WHEN (
															(
																(
																	CASE 
																		WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																			THEN ('NA')
																		WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																			THEN ('GA')
																		ELSE NULL
																		END
																	) = 'GA'
																)
															AND (NOT T3."VAT Prod_ Posting Group" LIKE 'DIFF%')
															)
														THEN ('GA - regelbest.')
													WHEN (
															(
																(
																	CASE 
																		WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																			THEN ('NA')
																		WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																			THEN ('GA')
																		ELSE NULL
																		END
																	) = 'NA'
																)
															AND ((left(T3."Inventory Posting Group", 2)) = 'NW')
															)
														THEN ('NA')
													WHEN (
															(
																(
																	CASE 
																		WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																			THEN ('NA')
																		WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																			THEN ('GA')
																		ELSE NULL
																		END
																	) = 'NA'
																)
															AND ((left(T3."Inventory Posting Group", 2)) = 'FA')
															)
														THEN ('NA')
													WHEN (
															(
																(
																	CASE 
																		WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																			THEN ('NA')
																		WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																			THEN ('GA')
																		ELSE NULL
																		END
																	) = 'NA'
																)
															AND ((left(T3."Inventory Posting Group", 2)) = 'VF')
															)
														THEN ('VFW')
													ELSE NULL
													END
												) = 'VFW'
											)
										AND (
											(
												(
													- 1 * datediff(day, (
															CASE 
																WHEN (T3."Date of Sale" IS NULL)
																	THEN (T2."Posting Date")
																ELSE (T3."Date of Sale")
																END
															), T3."Purchase Receipt Date")
													)
												) > 210
											)
										)
									THEN ('> 210 Tage')
								WHEN (
										(
											(
												CASE 
													WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
														THEN ('NA')
													WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
														THEN ('GA')
													ELSE NULL
													END
												) = 'GA'
											)
										AND (
											(
												(
													- 1 * datediff(day, (
															CASE 
																WHEN (T3."Date of Sale" IS NULL)
																	THEN (T2."Posting Date")
																ELSE (T3."Date of Sale")
																END
															), T3."Purchase Receipt Date")
													)
												) BETWEEN 0 AND 30
											)
										)
									THEN ('0 - 30 Tage')
								WHEN (
										(
											(
												CASE 
													WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
														THEN ('NA')
													WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
														THEN ('GA')
													ELSE NULL
													END
												) = 'GA'
											)
										AND (
											(
												(
													- 1 * datediff(day, (
															CASE 
																WHEN (T3."Date of Sale" IS NULL)
																	THEN (T2."Posting Date")
																ELSE (T3."Date of Sale")
																END
															), T3."Purchase Receipt Date")
													)
												) BETWEEN 31 AND 60
											)
										)
									THEN ('31 - 60 Tage')
								WHEN (
										(
											(
												CASE 
													WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
														THEN ('NA')
													WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
														THEN ('GA')
													ELSE NULL
													END
												) = 'GA'
											)
										AND (
											(
												(
													- 1 * datediff(day, (
															CASE 
																WHEN (T3."Date of Sale" IS NULL)
																	THEN (T2."Posting Date")
																ELSE (T3."Date of Sale")
																END
															), T3."Purchase Receipt Date")
													)
												) BETWEEN 61 AND 90
											)
										)
									THEN ('61 - 90 Tage')
								WHEN (
										(
											(
												CASE 
													WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
														THEN ('NA')
													WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
														THEN ('GA')
													ELSE NULL
													END
												) = 'GA'
											)
										AND (
											(
												(
													- 1 * datediff(day, (
															CASE 
																WHEN (T3."Date of Sale" IS NULL)
																	THEN (T2."Posting Date")
																ELSE (T3."Date of Sale")
																END
															), T3."Purchase Receipt Date")
													)
												) BETWEEN 91 AND 180
											)
										)
									THEN ('91 - 180 Tage')
								WHEN (
										(
											(
												CASE 
													WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
														THEN ('NA')
													WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
														THEN ('GA')
													ELSE NULL
													END
												) = 'GA'
											)
										AND (
											(
												(
													- 1 * datediff(day, (
															CASE 
																WHEN (T3."Date of Sale" IS NULL)
																	THEN (T2."Posting Date")
																ELSE (T3."Date of Sale")
																END
															), T3."Purchase Receipt Date")
													)
												) > 180
											)
										)
									THEN ('> 180 Tage')
								ELSE NULL
								END AS "Standtagestaffel",
							(
								- 1 * datediff(day, (
										CASE 
											WHEN (T3."Date of Sale" IS NULL)
												THEN (T2."Posting Date")
											ELSE (T3."Date of Sale")
											END
										), T3."Purchase Receipt Date")
								) AS "Standtage_ori",
							T3."Purchase Receipt Date" AS "Purchase Receipt Date",
							T3."Location Code" AS "Location Code",
							CASE 
								WHEN (
										(
											CASE 
												WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
													THEN ('NA')
												WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
													THEN ('GA')
												ELSE NULL
												END
											) = 'NA'
										)
									THEN (
											(right(((T2."VIN")), 7)) + ' / ' + T3."Model" + ' / ' + (
												CASE 
													WHEN (
															(
																(
																	CASE 
																		WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																			THEN ('NA')
																		WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																			THEN ('GA')
																		ELSE NULL
																		END
																	) = 'GA'
																)
															AND (T3."VAT Prod_ Posting Group" LIKE 'DIFF%')
															)
														THEN ('GA - diff.best.')
													WHEN (
															(
																(
																	CASE 
																		WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																			THEN ('NA')
																		WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																			THEN ('GA')
																		ELSE NULL
																		END
																	) = 'GA'
																)
															AND (NOT T3."VAT Prod_ Posting Group" LIKE 'DIFF%')
															)
														THEN ('GA - regelbest.')
													WHEN (
															(
																(
																	CASE 
																		WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																			THEN ('NA')
																		WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																			THEN ('GA')
																		ELSE NULL
																		END
																	) = 'NA'
																)
															AND ((left(T3."Inventory Posting Group", 2)) = 'NW')
															)
														THEN ('NA')
													WHEN (
															(
																(
																	CASE 
																		WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																			THEN ('NA')
																		WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																			THEN ('GA')
																		ELSE NULL
																		END
																	) = 'NA'
																)
															AND ((left(T3."Inventory Posting Group", 2)) = 'FA')
															)
														THEN ('NA')
													WHEN (
															(
																(
																	CASE 
																		WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
																			THEN ('NA')
																		WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
																			THEN ('GA')
																		ELSE NULL
																		END
																	) = 'NA'
																)
															AND ((left(T3."Inventory Posting Group", 2)) = 'VF')
															)
														THEN ('VFW')
													ELSE NULL
													END
												) + ' / ' + T3."Location Code" + ' / ' + (T5."No_" + ' - ' + T5."Name")
											)
								ELSE ((right(((T2."VIN")), 7)) + ' / ' + T3."Model" + ' / ' + T3."Location Code" + ' / ' + (T5."No_" + ' - ' + T5."Name"))
								END AS "FZG",
							CASE 
								WHEN (
										(
											(
												CASE 
													WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
														THEN ('NA')
													WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
														THEN ('GA')
													ELSE NULL
													END
												) = 'GA'
											)
										AND (T3."VAT Prod_ Posting Group" LIKE 'DIFF%')
										)
									THEN ('GA - diff.best.')
								WHEN (
										(
											(
												CASE 
													WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
														THEN ('NA')
													WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
														THEN ('GA')
													ELSE NULL
													END
												) = 'GA'
											)
										AND (NOT T3."VAT Prod_ Posting Group" LIKE 'DIFF%')
										)
									THEN ('GA - regelbest.')
								WHEN (
										(
											(
												CASE 
													WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
														THEN ('NA')
													WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
														THEN ('GA')
													ELSE NULL
													END
												) = 'NA'
											)
										AND ((left(T3."Inventory Posting Group", 2)) = 'NW')
										)
									THEN ('NA')
								WHEN (
										(
											(
												CASE 
													WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
														THEN ('NA')
													WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
														THEN ('GA')
													ELSE NULL
													END
												) = 'NA'
											)
										AND ((left(T3."Inventory Posting Group", 2)) = 'FA')
										)
									THEN ('NA')
								WHEN (
										(
											(
												CASE 
													WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
														THEN ('NA')
													WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
														THEN ('GA')
													ELSE NULL
													END
												) = 'NA'
											)
										AND ((left(T3."Inventory Posting Group", 2)) = 'VF')
										)
									THEN ('VFW')
								ELSE NULL
								END AS "Fahrzeugtyp_alt",
							T3."VAT Prod_ Posting Group" AS "Vat Prod Posting Group",
							CASE 
								WHEN ((left(T3."Inventory Posting Group", 2)) IN ('NW', 'VF', 'FA'))
									THEN ('NA')
								WHEN ((left(T3."Inventory Posting Group", 2)) = 'GW')
									THEN ('GA')
								ELSE NULL
								END AS "Fahrzeugart",
							T3."Market Segment Code" AS "Market Segment Code",
							(
								CASE 
									WHEN (
											NOT (
												CASE 
													WHEN (T3."Make Code" IN ('BMW', 'BMW I', 'BMWI', 'BMW-MINI', 'BMW-MOT'))
														THEN (T3."Make Code")
													ELSE ('Fremdfabrikat')
													END
												) IN ('Fremdfabrikat')
											)
										THEN (
												(
													CASE 
														WHEN (
																(
																	(
																		CASE 
																			WHEN (T3."Make Code" IN ('BMW', 'BMW I', 'BMWI', 'BMW-MINI', 'BMW-MOT'))
																				THEN (T3."Make Code")
																			ELSE ('Fremdfabrikat')
																			END
																		) = 'BMW'
																	)
																AND ((left(T4."Description", 1)) BETWEEN '1' AND '9')
																)
															THEN ((left(T4."Description", 1)) + 'er')
														WHEN (
																(
																	(
																		CASE 
																			WHEN (T3."Make Code" IN ('BMW', 'BMW I', 'BMWI', 'BMW-MINI', 'BMW-MOT'))
																				THEN (T3."Make Code")
																			ELSE ('Fremdfabrikat')
																			END
																		) = 'BMW'
																	)
																AND ((left(T4."Description", 1)) BETWEEN 'A' AND 'Z')
																)
															THEN ((left(T4."Description", 2)))
														WHEN (
																(
																	(
																		CASE 
																			WHEN (T3."Make Code" IN ('BMW', 'BMW I', 'BMWI', 'BMW-MINI', 'BMW-MOT'))
																				THEN (T3."Make Code")
																			ELSE ('Fremdfabrikat')
																			END
																		) = 'BMW-MINI'
																	)
																AND (
																	(T4."Description" LIKE '%3-T%')
																	OR (T3."Model" LIKE '%3-T%')
																	)
																)
															THEN ('3-T�rer')
														WHEN (
																(
																	(
																		CASE 
																			WHEN (T3."Make Code" IN ('BMW', 'BMW I', 'BMWI', 'BMW-MINI', 'BMW-MOT'))
																				THEN (T3."Make Code")
																			ELSE ('Fremdfabrikat')
																			END
																		) = 'BMW-MINI'
																	)
																AND (
																	(T4."Description" LIKE '%5-T%')
																	OR (T3."Model" LIKE '%5-T%')
																	)
																)
															THEN ('5-T�rer')
														WHEN (
																(
																	(
																		CASE 
																			WHEN (T3."Make Code" IN ('BMW', 'BMW I', 'BMWI', 'BMW-MINI', 'BMW-MOT'))
																				THEN (T3."Make Code")
																			ELSE ('Fremdfabrikat')
																			END
																		) = 'BMW-MINI'
																	)
																AND (
																	(T4."Description" LIKE '%Club%')
																	OR (T3."Model" LIKE '%Club%')
																	)
																)
															THEN ('Clubman')
														WHEN (
																(
																	(
																		CASE 
																			WHEN (T3."Make Code" IN ('BMW', 'BMW I', 'BMWI', 'BMW-MINI', 'BMW-MOT'))
																				THEN (T3."Make Code")
																			ELSE ('Fremdfabrikat')
																			END
																		) = 'BMW-MINI'
																	)
																AND (
																	(T4."Description" LIKE '%Count%')
																	OR (T3."Model" LIKE '%Count%')
																	)
																)
															THEN ('Countryman')
														WHEN (
																(
																	(
																		CASE 
																			WHEN (T3."Make Code" IN ('BMW', 'BMW I', 'BMWI', 'BMW-MINI', 'BMW-MOT'))
																				THEN (T3."Make Code")
																			ELSE ('Fremdfabrikat')
																			END
																		) = 'BMW-MINI'
																	)
																AND (
																	(T4."Description" LIKE '%Cou%')
																	OR (T3."Model" LIKE '%Cou%')
																	)
																)
															THEN ('Coupe')
														WHEN (
																(
																	(
																		CASE 
																			WHEN (T3."Make Code" IN ('BMW', 'BMW I', 'BMWI', 'BMW-MINI', 'BMW-MOT'))
																				THEN (T3."Make Code")
																			ELSE ('Fremdfabrikat')
																			END
																		) = 'BMW-MINI'
																	)
																AND (
																	(T4."Description" LIKE '%Hatch%')
																	OR (T3."Model" LIKE '%Hatch%')
																	)
																)
															THEN ('Hatch')
														WHEN (
																(
																	(
																		CASE 
																			WHEN (T3."Make Code" IN ('BMW', 'BMW I', 'BMWI', 'BMW-MINI', 'BMW-MOT'))
																				THEN (T3."Make Code")
																			ELSE ('Fremdfabrikat')
																			END
																		) = 'BMW-MINI'
																	)
																AND (
																	(T4."Description" LIKE '%Pace%')
																	OR (T3."Model" LIKE '%Pace%')
																	)
																)
															THEN ('Paceman')
														WHEN (
																(
																	(
																		CASE 
																			WHEN (T3."Make Code" IN ('BMW', 'BMW I', 'BMWI', 'BMW-MINI', 'BMW-MOT'))
																				THEN (T3."Make Code")
																			ELSE ('Fremdfabrikat')
																			END
																		) = 'BMW-MINI'
																	)
																AND (
																	(T4."Description" LIKE '%Road%')
																	OR (T3."Model" LIKE '%Road%')
																	)
																)
															THEN ('Roadster')
														WHEN (
																(
																	(
																		CASE 
																			WHEN (T3."Make Code" IN ('BMW', 'BMW I', 'BMWI', 'BMW-MINI', 'BMW-MOT'))
																				THEN (T3."Make Code")
																			ELSE ('Fremdfabrikat')
																			END
																		) = 'BMW-MINI'
																	)
																AND (
																	(T4."Description" LIKE '%Cab%')
																	OR (T3."Model" LIKE '%Cab%')
																	)
																)
															THEN ('Cabrio')
														ELSE (T4."Description")
														END
													)
												)
									ELSE ('Fremd')
									END
								) AS "Model",
							T3."Make Code" AS "Make Code_Vehicle",
							CASE 
								WHEN (
										(T2."Branch Code" = 'TIM')
										OR (T2."Branch Code" = '')
										)
									THEN ('10')
								WHEN (T2."Branch Code" = 'TNE')
									THEN ('20')
								ELSE ((left(T1."Global Dimension 1 Code", 2)))
								END AS "Standort_alt",
							T3."Model No_" AS "Model No",
							T3."Class" AS "Class",
							T3."Type" AS "Type",
							T3."Vehicle Status" AS "Vehicle Status",
							T3."VIN" AS "Vin_Vehicle",
							T2."Veh_ Source Code" AS "Veh Source Code",
							T2."Book No_" AS "Book No",
							(T2."VIN") AS "Vin",
							T2."Main Area" AS "Main Area",
							T2."Branch Code" AS "Branch Code",
							T2."No_ Series" AS "No Series",
							T2."Source No_" AS "Source No",
							T2."Source Type" AS "Source Type",
							T2."Document Date" AS "Document Date",
							T2."Credit Amount" AS "Credit Amount",
							T2."Debit Amount" AS "Debit Amount",
							T2."Quantity" AS "Quantity",
							T2."Source Code" AS "Source Code",
							T2."User ID" AS "User Id",
							T2."Global Dimension 2 Code" AS "Make Code",
							T2."Global Dimension 1 Code" AS "Department Code",
							T2."Bal_ Account No_" AS "Bal Account No",
							T2."Amount" AS "Amount",
							T2."Description" AS "Description",
							T2."Document No_" AS "Document No",
							T2."Document Type" AS "Document Type",
							T2."Posting Date" AS "Posting Date",
							T2."G_L Account No_" AS "G L Account No",
							T2."Entry No_" AS "Entry No",
							T1."Income_Balance" AS "Income Balance",
							T1."Global Dimension 2 Code" AS "Make Code_2",
							T1."Global Dimension 1 Code" AS "Department Code_2",
							T1."Account Type" AS "Account Type",
							T1."Name" AS "Name",
							T1."No_" AS "No"
						FROM "Vogl7x"."dbo"."BMW AH Vogl$G_L Account" T1,
							(
								(
									(
										(
											(
												(
													"Vogl7x"."dbo"."BMW AH Vogl$G_L Entry" T2 LEFT JOIN "Vogl7x"."dbo"."BMW AH Vogl$Vehicle" T3 ON T3."VIN" = T2."VIN"
													) LEFT JOIN "Vogl7x"."dbo"."BMW AH Vogl$Item" T4 ON T4."No_" = T3."Model No_"
												) LEFT JOIN "Vogl7x"."dbo"."BMW AH Vogl$Customer" T5 ON T3."Customer No_" = T5."No_"
											) LEFT JOIN "Vogl7x"."dbo"."BMW AH Vogl$Customer" T6 ON T3."Old Customer No_" = T6."No_"
										) LEFT JOIN "Vogl7x"."dbo"."BMW AH Vogl$Vehicle Ledger Entry" T8 ON (
											(T8."VIN" = T3."VIN")
											AND (T8."Current Sales Ledger Entry" = 1)
											)
										AND (T8."Book No_" = T3."Current Book No_")
									) LEFT JOIN "Vogl7x"."dbo"."BMW AH Vogl$Salesperson_Purchaser" T7 ON T8."Salespers__Purch_ Code" = T7."Code"
								)
						WHERE (T1."No_" = T2."G_L Account No_")
							AND (
								(
									(
										(
											(
												(
													(
														(
															(
																(T1."No_" IN ('88200', '78200', '78700', '78710', '79000', '79030', '79100', '79130', '88210', '88220', '88230', '88240', '88290', '88310', '88320', '88400', '88410', '88420', '88430', '88560', '88570', '88700', '88710', '88720', '88730', '88740', '88750', '88760', '88770', '88780', '88790', '89000', '89030', '88580', '88581', '88582', '78580', '88584', '88583'))
																OR (T1."No_" BETWEEN '71000' AND '72990')
																)
															OR (T1."No_" BETWEEN '81000' AND '82990')
															)
														OR (
															(
																(T1."No_" LIKE '4%')
																AND (T2."Book No_" <> ' ')
																)
															AND (T2."Posting Date" >= T3."Purchase Receipt Date")
															)
														)
													AND (NOT T2."Description" IN ('GuV-Konten Nullstellung', 'GuV Konten Nullstellung'))
													)
												AND (T2."Posting Date" >= convert(DATETIME, '2019-12-01 00:00:00.000'))
												)
											AND (((T2."VIN")) <> ' ')
											)
										AND (T3."Inventory Posting Group" <> 'GROSSKD')
										)
									AND (T3."Current Book No_" = T2."Book No_")
									)
								AND (T3."Date of Sale" >= convert(DATETIME, '2020-01-01 00:00:00.000'))
								)
						) D3
					) D7
				) D1
			WHERE (
					("Summe_Betrag" <> 0)
					AND (NOT c138 BETWEEN - 0.1 AND 0.1)
					)
			) D6
		) D5
	) D2
	-- order by "Summe EK-FZG" asc,"Vin" asc,"Posting Date" asc,"Document No" asc
