DROP VIEW LD0V0YREFERENCEPERSONS
;
CREATE VIEW LD0V0YREFERENCEPERSONS AS
SELECT  
Y.REFNR, 
Y.PNR, 
Y.REFPNR, 
Y.REFERENS, 
Y.UPDDAT, 
Y.UPDSIGN, 
Y.PERSID,
A.NAMN,
A.EPOSTHEM,
A.EPOSTARB, 
A.KUNDNUMMER REFPERSONKEY, 
A.ADRESS, 
A.COADR, 
A.POSTNR, 
A.ORT, 
A.HEMTEL, 
A.ARBTEL, 
A.MOBIL,
A.NYCKKOD, 
A.ADRSKYDD, 
A.OMRADE, 
A.FOLKKOM, 
Q1.KLARTEXT FOLKKOM_T 
FROM LD0V0Y Y
INNER JOIN LD0V0A A ON Y.REFPNR = A.PNR 
LEFT OUTER JOIN LD0V0Q01 Q1 ON Q1.KODTYP='KOMU' AND Q1.KOD = A.FOLKKOM
;