DROP VIEW LD0V1U10Ext
;

CREATE VIEW LD0V1U10Ext 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 'ANVISANDEORGTYP',
               '' as 'ANVISANDEORGINTERN',
               0 AS 'ANVISANDEORGEXTERN',
               '' as 'ANVISANDEHANDL',
               '' as 'ANVISANDEFROM',
               '' as 'ANVISANDETOM',
               0 as 'ANSVARIGFOR',
               '' as 'ANSVARIGORG',
               '' as 'ANSVARIGHANDL'
FROM LD0VLU10 U10
join LD0V0A A ON U10.PERSONNR = A.PNR
left outer join LD0V0U01 U01 on U10.PERSONNR = U01.PERSONNR
;
