IF EXISTS (SELECT 1 FROM SYS.VIEWS WHERE NAME='LD0VAA0ActivitySchedule')
BEGIN
DROP VIEW LD0VAA0ActivitySchedule 
END
;

IF EXISTS (SELECT 1 FROM SYS.VIEWS WHERE NAME='LD0VAA0LMActivitySchedule')
BEGIN
DROP VIEW LD0VAA0LMActivitySchedule 
END
;

CREATE VIEW LD0VAA0LMActivitySchedule
AS 
SELECT
U85.*
, Q.KLARTEXT AS OVRIGPLATS_T
, U70.BENAMNING AS ENKELPLATS_T
, U60.BENAMNING AS PRAKPROJ_T
, Q1.KLARTEXT AS AKTIVITET_T
FROM LD0V0U85 AS U85 
LEFT OUTER JOIN LD0V0Q01 AS Q ON Q.KODTYP = 'LNOVRPLATS' AND U85.OVRIGPLATS = Q.KOD
LEFT OUTER JOIN LD0V0U70 AS U70 ON U85.ENKELPLATSNR = U70.ENKELPLATSNR
LEFT OUTER JOIN LD0V0U60 AS U60 ON U85.PRAKPROJNR = U60.PRAKPROJNR
LEFT OUTER JOIN LD0VYU34 AS U34 ON U85.PLANAKTIVITETNR = U34.PLANAKTIVITETNR 
LEFT OUTER JOIN LD0V0Q01 AS Q1 ON Q1.KODTYP = 'LNAKTIV' AND Q1.KOD = u34.AKTIVITET AND u34.PLANAKTIVITETNR = U85.PLANAKTIVITETNR
;
