DROP VIEW LD0VAA0Enrollment
;

CREATE VIEW LD0VAA0Enrollment
AS 
SELECT
 U10.*
,Q1.KLARTEXT AS TYPAVSLUT_T
,Q2.KLARTEXT AS AVSLUTORS_T
,Q3.KLARTEXT AS AVSLUTKOMMUN_T
,Q4.KLARTEXT AS AVSLUTLAND_T
,Q5.KLARTEXT AS INSKRTYP_T
,Q6.KLARTEXT AS ANVISTYP_T

FROM LD0VYU10 AS U10
LEFT OUTER JOIN LD0V0Q01 AS Q1 ON Q1.KODTYP = 'LNTYPAVSL' AND U10.TYPAVSLUT = Q1.KOD
LEFT OUTER JOIN LD0V0Q01 AS Q2 ON Q2.KODTYP = 'LNAVSLORS' AND U10.AVSLUTORS = Q2.KOD
LEFT OUTER JOIN LD0V0Q01 AS Q3 ON Q3.KODTYP = 'KOMU' AND U10.AVSLUTKOMMUN = Q3.KOD
LEFT OUTER JOIN LD0V0Q01 AS Q4 ON Q4.KODTYP = 'LAND' AND U10.AVSLUTLAND = Q4.KOD
LEFT OUTER JOIN LD0V0Q01 AS Q5 ON Q5.KODTYP = 'LNINSKTYP' AND U10.INSKRTYP = Q5.KOD
LEFT OUTER JOIN LD0V0Q01 AS Q6 ON Q6.KODTYP = 'LNANVISTYP' AND U10.ANVISTYP = Q6.KOD
;
