DROP VIEW LD0V0U90
;
CREATE VIEW LD0V0U90
AS SELECT * FROM LD0P0U90 U90
 WHERE (EXISTS (SELECT 'X' FROM LD0V5AJD AJD
     WHERE U90.BESTORGENHNR LIKE AJD.JFRDTA10
     AND AJD.VYNAMN='AMUPPDBEST'))
AND	(EXISTS (SELECT 'X' FROM LD0P0SEKR SEKR
								  JOIN LD0V0ANVANDARE AJD
								  ON AJD.CSSANV=SEKR.CSSANV
								  AND SEKR.PNR=U90.PNR)
							OR NOT EXISTS (SELECT 'X' FROM LD0P0SEKR SEKR WHERE SEKR.PNR=U90.PNR))

WITH CHECK OPTION
;