IF EXISTS (SELECT 1 FROM SYS.VIEWS WHERE NAME='LD0V0GoalJudgement')
BEGIN
DROP VIEW LD0V0GoalJudgement 
END
GO
CREATE VIEW LD0V0GoalJudgement
AS
SELECT 
M13.*, 
Q01_1.KLARTEXT AS MALSRUBNR_T, 
Q01_2.KLARTEXT AS MALSOMDOME_T
FROM 
LD0V0M13 M13 
LEFT JOIN LD0V0Q01 Q01_1 ON Q01_1.KODTYP = 'MALSATTRUB' AND M13.MALSRUBNR = Q01_1.KOD
LEFT JOIN LD0V0Q01 Q01_2 ON Q01_2.KODTYP = 'MALUPPFYLL' AND M13.MALSOMDOME = Q01_2.KOD
GO
GRANT ALL ON LD0V0GoalJudgement TO LD0ROANV
GO