IF EXISTS (SELECT 1 FROM SYS.VIEWS WHERE NAME='LD0VAA0SurveyLanguageLevelSFI')
BEGIN
DROP VIEW LD0VAA0SurveyLanguageLevelSFI
END
;

CREATE VIEW LD0VAA0SurveyLanguageLevelSFI AS SELECT
U22.*, 
Q1.KLARTEXT AS KURSPLAN_T, Q2.KLARTEXT AS RESULTAT_T, Q3.KLARTEXT AS KOMMUN_T
FROM LD0P0U22 U22
LEFT OUTER JOIN ld0v0q01 Q1 ON Q1.KODTYP = 'LNKURSPLAN' AND Q1.KOD = U22.KURSPLAN
LEFT OUTER JOIN ld0v0q01 Q2 ON Q2.KODTYP = 'LNRESULSFI' AND Q2.KOD = U22.RESULTAT
LEFT OUTER JOIN ld0v0q01 Q3 ON Q3.KODTYP = 'KOMU' AND Q3.KOD = U22.KOMMUN
;

