DROP VIEW LD0V3U10Ext 
;

CREATE VIEW LD0V3U10Ext AS SELECT
       U10.INSKRIVNINGSNR,
       U10.PERSONNR,
       U10.INLEDDAT,
       U10.AVSLUTDAT,
       U10.UPDDAT,
       U10.UPDSIGN,
       U10.FORLANGDINTRO,
       U10.TYPAVSLUT,
       U10.AVSLUTORS,
       U10.AVSLUTKOMMUN,
       U10.AVSLUTLAND,
       U10.KOMMUNUTLAND,
       U10.ORGID,
       U10.ORGENHNR,
       u10.YRKEAVSLUT,
       u10.INSKRTYP,
       isnull(U01.INGENUTBILDN, 0) as 'INGENUTBILDN',
       isnull(U01.INGENARBLIVERF, 0) as 'INGENARBLIVERF',
       isnull(U01.INGENFARDIGHET, 0) as 'INGENFARDIGHET',
       U10.UTANARB,
       u10.YRKEAVSLUT_2012,
       A.NAMN,
       A.ADRESS,
       A.COADR,
       A.POSTNR,
       A.ORT,
       A.HEMTEL,
       A.ARBTEL,
       A.KADRESS,
       A.KCOADR,
       A.KPOSTNR,
       A.KORT,
       A.KHEMTEL,
       A.KUATDAT,
       A.KFLYKTING,
       A.CIVKOD,
       A.CIVDAT,
       A.MEDBSKAP,
       A.MEDBDAT,
       A.FODLAN,
       A.FODLAND,
       A.OMRADE,
       A.FOLKFORS,
       A.FOLKLAN,
       A.FOLKKOM,
       A.FOLKDAT,
       A.AVREGORS,
       A.AVREGDAT,
       A.ADRSKYDD,
       A.HEMLIGTFN,
       A.UPDDAT AS PUPDDAT,
       A.UPDSIGN AS PUPDSIGN,
       A.KUPDDAT,
       A.KUPDSIGN,
       A.KOMDEL,
       A.BETJOMR,
       A.NYCKKOD,
       A.FODDAT,
       A.KON,
       A.PERSTEL,
       A.MOBIL,
       A.FAX,
       A.EPOSTHEM,
       A.EPOSTARB,
       A.MODMAL,
       A.KOMSPRAK,
       A.KOMSPRAK2,
       A.KOMSPRAK3,
       A.TOLKBEHOV,
       A.INVANDAT,
               A.KUNDNUMMER,
               0 as 'U11ANVISORGTYP',
               '' as 'U11ANVISORGINTERN',
               0 AS 'U11ORGEXTERN',
               '' as 'U11HANDLAGGARE',
               '' as 'U11FROMDAT',
               '' as 'U11TOMDAT',
               0 as 'U11TYPAVSLUT',
               0 as 'U11AVSLUTORS',
               0 as 'U11AVSLUTKOMMUN',
               0 as 'U11AVSLUTLAND',
               '' as 'U11KOMMUNUTLAND',
               '' as 'U11YRKEAVSLUT',
               '' as 'U11YRKEAVSLUT_2012',
               U12.ANSVARIGFOR as 'U12ANSVARIGFOR',
               U12.ANSVARIGORG as 'U12ANSVARIGORG',
               U12.HANDLAGGARE as 'U12HANDLAGGARE'
FROM LD0VLU10 U10
join LD0V0U12 U12 ON U12.INSKRIVNINGSNR = U10.INSKRIVNINGSNR
join LD0V0A A ON U10.PERSONNR = A.PNR
left outer join LD0V0U01 U01 on U10.PERSONNR = U01.PERSONNR
;

