SELECT T1."KONTO" AS "Konto",
	T1."ACCT_NR" AS "Acct Nr",
	T1."KONTO_BEZEICHNUNG" AS "Konto Bezeichnung",
	T1."GUV_BILANZ" AS "Guv Bilanz",
	T1."KONTO_KST" AS "Konto Kst",
	T1."KONTO_STK" AS "Konto Stk",
	T1."KONTO_1" AS "Konto 1",
	T1."KONTO_2" AS "Konto 2",
	T1."KONTO_3" AS "Konto 3",
	T1."KONTO_4" AS "Konto 4",
	T1."KONTO_5" AS "Konto 5",
	T1."EBENE1" AS "Ebene1",
	T1."EBENE2" AS "Ebene2",
	T1."EBENE3" AS "Ebene3",
	T1."EBENE4" AS "Ebene4",
	T1."EBENE5" AS "Ebene5",
	T1."EBENE6" AS "Ebene6",
	T1."EBENE7" AS "Ebene7",
	T1."EBENE8" AS "Ebene8",
	T1."EBENE9" AS "Ebene9",
	T1."EBENE10" AS "Ebene10",
	T1."EBENE71" AS "Ebene71",
	T1."EBENE72" AS "Ebene72",
	T1."EBENE73" AS "Ebene73",
	T1."EBENE74" AS "Ebene74",
	T1."EBENE75" AS "Ebene75",
	T1."EBENE76" AS "Ebene76",
	T1."EBENE77" AS "Ebene77",
	T1."EBENE78" AS "Ebene78",
	T1."EBENE79" AS "Ebene79",
	T1."EBENE80" AS "Ebene80",
	T1."EBENE81" AS "Ebene81",
	T1."EBENE82" AS "Ebene82",
	T1."EBENE83" AS "Ebene83",
	T1."EBENE84" AS "Ebene84",
	T1."EBENE85" AS "Ebene85",
	T1."EBENE86" AS "Ebene86",
	T1."EBENE87" AS "Ebene87",
	T1."EBENE88" AS "Ebene88",
	T1."EBENE89" AS "Ebene89",
	T1."EBENE90" AS "Ebene90",
	T1."KONTO_GRUPPE" AS "Konto Gruppe",
	T1."SUSA" AS "Susa",
	CASE 
		WHEN (T1."GUV_BILANZ" = '2')
			THEN (
					(
						CASE 
							WHEN (((locate('_', T1."KONTO_GRUPPE", 1))) = 5)
								THEN ((left(((left(T1."KONTO_GRUPPE", ((locate('_', T1."KONTO_GRUPPE", 1)))))), 4)))
							WHEN (((locate('_', T1."KONTO_GRUPPE", 1))) = 6)
								THEN ((left(((left(T1."KONTO_GRUPPE", ((locate('_', T1."KONTO_GRUPPE", 1)))))), 5)))
							ELSE NULL
							END
						) + ' - ' + T1."KONTO_BEZEICHNUNG"
					)
		ELSE (T1."KONTO_GRUPPE")
		END AS "Konto Gesamt",
	(locate('_', T1."KONTO_GRUPPE", 1)) AS "_Stelle",
	(left(T1."KONTO_GRUPPE", ((locate('_', T1."KONTO_GRUPPE", 1))))) AS "LINKS (  Konto Gruppe ; _Stelle)",
	CASE 
		WHEN (((locate('_', T1."KONTO_GRUPPE", 1))) = 5)
			THEN ((left(((left(T1."KONTO_GRUPPE", ((locate('_', T1."KONTO_GRUPPE", 1)))))), 4)))
		WHEN (((locate('_', T1."KONTO_GRUPPE", 1))) = 6)
			THEN ((left(((left(T1."KONTO_GRUPPE", ((locate('_', T1."KONTO_GRUPPE", 1)))))), 5)))
		ELSE NULL
		END AS "Kontonummer"
FROM "SKR51_Uebersetzung.csv" T1
