DROP VIEW LD0VAA0SearchFatherhoodIncomingErrand
;

CREATE VIEW LD0VAA0SearchFatherhoodIncomingErrand
AS
SELECT DISTINCT
E50.*,
Q01.KLARTEXT MODERCIVILSTANDKOD_T,
E56.STATUS SENDSTATUS
  FROM LD0P0E50 E50
  LEFT JOIN LD0P0E55 E55 
  ON E50.FSUNDERATTELSENR=E55.FSUNDERATTELSENR
  LEFT JOIN LD0P0E56 E56
  ON E55.FSUPPGIFTNR=E56.FSUPPGIFTNR
  LEFT JOIN LD0V0Q01 Q01 ON E50.MODERCIVILSTANDKOD = Q01.EXTKOD AND Q01.KODTYP = 'CIVS'
;