IF exists(SELECT * FROM sysobjects WHERE name = 'LD0SPDBTestCases')
	DROP PROCEDURE LD0SPDBTestCases
GO

CREATE PROCEDURE LD0SPDBTestCases 
AS
BEGIN

SELECT * INTO #failedTests FROM(  
SELECT 'AktualiseringReasonMissingCodeText' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYH WHERE LD0VYH.AORSAK > 0 AND NOT EXISTS (SELECT 'X' FROM LD0V0Q01 WHERE LD0V0Q01.KODTYP = 'AKTUORSAK' AND LD0V0Q01.KOD = LD0VYH.AORSAK)) AS Result UNION
SELECT 'AktualiseringStatusMissinginAktualiseringRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0AAktualiseringStatus WHERE NOT EXISTS (SELECT 'X' FROM LD0VYH WHERE LD0VYH.AKTUALNR = LD0V0AAktualiseringStatus.AKTUALNR)) AS Result UNION
SELECT 'AktualiseringWrongDates' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYH WHERE NOT LD0VYH.ADATUM LIKE '19%' AND NOT LD0VYH.ADATUM LIKE '20%') AS Result UNION
SELECT 'AlertsHeadMissingAktualisering' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYBVK WHERE LD0VYBVK.HUVUDOBJID = 7040 AND NOT EXISTS(SELECT 'X' FROM LD0VYH WHERE LD0VYH.AKTUALNR = LD0VYBVK.HUVUDOBJNR)) AS Result UNION
SELECT 'AlertsHeadMissingAssignment' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYBVK WHERE LD0VYBVK.HUVUDOBJID = 28059 AND NOT EXISTS(SELECT 'X' FROM LD0VYN90 WHERE LD0VYN90.UPPDRAGNR = LD0VYBVK.HUVUDOBJNR)) AS Result UNION
SELECT 'AlertsHeadMissingExecution' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYBVK WHERE LD0VYBVK.HUVUDOBJID = 7025 AND NOT EXISTS(SELECT 'X' FROM LD0VYC WHERE LD0VYC.AEVERKNR = LD0VYBVK.HUVUDOBJNR)) AS Result UNION
SELECT 'AlertsHeadMissingInvestigation' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYBVK WHERE LD0VYBVK.HUVUDOBJID = 7017 AND NOT EXISTS(SELECT 'X' FROM LD0VYC WHERE LD0VYC.AEVERKNR = LD0VYBVK.HUVUDOBJNR)) AS Result UNION
SELECT 'AlertsHeadMissingService' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYBVK WHERE LD0VYBVK.HUVUDOBJID = 7083 AND NOT EXISTS(SELECT 'X' FROM LD0VYC20 WHERE LD0VYC20.INSNR = LD0VYBVK.HUVUDOBJNR)) AS Result UNION
SELECT 'AlertsMissingAktualisering' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYBVK WHERE LD0VYBVK.OBJEKTID = 7040 AND NOT EXISTS(SELECT 'X' FROM LD0VYH WHERE LD0VYH.AKTUALNR = LD0VYBVK.OBJEKTNR)) AS Result UNION
SELECT 'AlertsMissingAssignment' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYBVK WHERE LD0VYBVK.OBJEKTID = 28059 AND NOT EXISTS(SELECT 'X' FROM LD0VYN90 WHERE LD0VYN90.UPPDRAGNR = LD0VYBVK.OBJEKTNR)) AS Result UNION
SELECT 'AlertsMissingCalculation' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYBVK WHERE LD0VYBVK.OBJEKTID = 7005 AND NOT EXISTS(SELECT 'X' FROM LD0VYD WHERE LD0VYD.BERAKNR = LD0VYBVK.OBJEKTNR)) AS Result UNION
SELECT 'AlertsMissingDecision' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYBVK WHERE LD0VYBVK.OBJEKTID = 7012 AND NOT EXISTS(SELECT 'X' FROM LD0VYE WHERE LD0VYE.BESLUTNR = LD0VYBVK.OBJEKTNR)) AS Result UNION
SELECT 'AlertsMissingExecution' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYBVK WHERE LD0VYBVK.OBJEKTID = 7025 AND NOT EXISTS(SELECT 'X' FROM LD0VYC WHERE LD0VYC.AEVERKNR = LD0VYBVK.OBJEKTNR)) AS Result UNION
SELECT 'AlertsMissingHousehold' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYBVK WHERE LD0VYBVK.OBJEKTID = 7001 AND NOT EXISTS(SELECT 'X' FROM LD0V0K WHERE LD0V0K.HUSHLNR = LD0VYBVK.OBJEKTNR)) AS Result UNION
SELECT 'AlertsMissingInpayment' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYBVK WHERE LD0VYBVK.OBJEKTID = 7053 AND NOT EXISTS(SELECT 'X' FROM LD0VYF WHERE LD0VYF.BETALNR = LD0VYBVK.OBJEKTNR)) AS Result UNION
SELECT 'AlertsMissingInvestigation' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYBVK WHERE LD0VYBVK.OBJEKTID = 7017 AND NOT EXISTS(SELECT 'X' FROM LD0VYC WHERE LD0VYC.AEVERKNR = LD0VYBVK.OBJEKTNR)) AS Result UNION
SELECT 'AlertsMissingRequisition ' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYBVK WHERE LD0VYBVK.OBJEKTID = 7054 AND NOT EXISTS(SELECT 'X' FROM LD0VYG WHERE LD0VYG.REKVNR = LD0VYBVK.OBJEKTNR)) AS Result UNION
SELECT 'AlertsMissingResourceAllocation' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYBVK WHERE LD0VYBVK.OBJEKTID = 7254 AND NOT EXISTS(SELECT 'X' FROM LD0VYN70 WHERE LD0VYN70.RESTILLDNR = LD0VYBVK.OBJEKTNR)) AS Result UNION
SELECT 'AlertsMissingService' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYBVK WHERE LD0VYBVK.OBJEKTID = 7083 AND NOT EXISTS(SELECT 'X' FROM LD0VYC20 WHERE LD0VYC20.INSNR = LD0VYBVK.OBJEKTNR)) AS Result UNION
SELECT 'AlertsWithMissingCaseworker' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYBVK WHERE LD0VYBVK.HAND > ' ' AND NOT LD0VYBVK.HAND IN(SELECT HAND FROM LD0V0I)) AS Result UNION
SELECT 'AlertsWithMissingPerson' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYBVK WHERE LD0VYBVK.PNR > ' ' AND NOT PNR IN(SELECT PNR FROM LD0V0A)) AS Result UNION
SELECT 'ApplicationsWithNotDeletedDrafts' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VAA0INCOMPAPP WHERE ID IN (SELECT LD0VYH.APPLICATIONID FROM LD0VYH)) AS Result UNION
SELECT 'AreaRowsMissingInAreaRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0J11 WHERE NOT EXISTS (SELECT 'X' FROM LD0V0J10 WHERE LD0V0J10.OMRID = LD0V0J11.OMRID)) AS Result UNION
SELECT 'AreasMissingToOrFromDate' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0J10 WHERE LD0V0J10.FOMDAT = ' ' OR LD0V0J10.TOMDAT = ' ') AS Result UNION
SELECT 'AssignmentDecisionMissinInDecisionRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYN90 N90 WHERE N90.BESLUTNR > 0 AND NOT EXISTS (SELECT 'X' FROM LD0VYE E WHERE E.BESLUTNR = N90.BESLUTNR)) AS Result UNION
SELECT 'AssignmentIFODecisionMissinInDecisionRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYN900 N900 WHERE N900.BESLUTNR > 0 AND NOT EXISTS (SELECT 'X' FROM LD0VYE E WHERE E.BESLUTNR = N900.BESLUTNR)) AS Result UNION
SELECT 'AssignmentIfoMissingDecision' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0N900 WHERE LD0V0N900.BESLUTNR = 0) AS Result UNION
SELECT 'AssignmentIFOOrganizationMissinInOrganizationRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYN900 N900 WHERE NOT EXISTS (SELECT 'X' FROM LD0V0J01 J01 WHERE J01.ORGID = N900.ORGID AND J01.ORGENHNR = N900.ORGENHNR)) AS Result UNION
SELECT 'AssignmentIfoPartMissingAssignmentIfo' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0N901 WHERE NOT EXISTS (SELECT 'X' FROM LD0VYN900 WHERE LD0VYN900.UPPDRAGIFONR = LD0V0N901.UPPDRAGIFONR)) AS Result UNION
SELECT 'AssignmentIFOPartOrganizationMissinInOrganizationRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYN901 N901 WHERE NOT EXISTS (SELECT 'X' FROM LD0V0J01 J01 WHERE J01.ORGID = N901.ORGID AND J01.ORGENHNR = N901.ORGENHNR)) AS Result UNION
SELECT 'AssignmentIFOPersonMissinInPersonRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYN900 N900 WHERE NOT N900.PNR = ' ' AND NOT EXISTS (SELECT 'X' FROM LD0V0A A WHERE A.PNR = N900.PNR)) AS Result UNION
SELECT 'AssignmentOrganizationMissinInOrganizationRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYN90 N90 WHERE NOT N90.ORGENHNR = ' ' AND NOT EXISTS (SELECT 'X' FROM LD0V0J01 J01 WHERE J01.ORGID = N90.ORGID AND J01.ORGENHNR = N90.ORGENHNR)) AS Result UNION
SELECT 'AssignmentPersonMissinInPersonRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYN90 N90 WHERE NOT N90.PNR = ' ' AND NOT EXISTS (SELECT 'X' FROM LD0V0A A WHERE A.PNR = N90.PNR)) AS Result UNION
SELECT 'AttachedDocumentAssignmentIfoPartMissingAttachedDocument' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0T431 WHERE NOT EXISTS (SELECT 'X' FROM LD0V0T43 WHERE LD0V0T43.INFOGANR = LD0V0T431.INFOGANR)) AS Result UNION
SELECT 'AuditLogsMissingOrigin' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM PCCV0LOG WHERE PCCV0LOG.URSPRUNG = ' ' ) AS Result UNION
SELECT 'BalanceAdjustmentMissingJournalEvent' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYF WHERE BETTYP = 90 AND NOT EXISTS (SELECT 'X' FROM LD0VYC11 WHERE LD0VYC11.HAGNR = LD0VYF.BETALNR AND HTYP = 140) AND BETALNR > 3269) AS Result UNION
SELECT 'BalanceForInvoiceMissingInvoice' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0C24 WHERE LD0V0C24.AGARTYP = 4 AND NOT LD0V0C24.AGARNR IN(SELECT LD0V0N30.FAKTURANR FROM LD0V0N30)) AS Result UNION
SELECT 'BalanceForRequsitionMissingInvoiceRow' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0C24 WHERE LD0V0C24.AGARTYP = 3 AND NOT LD0V0C24.AGARNR IN(SELECT LD0V0G04.FAKTRADNR FROM LD0V0G04)) AS Result UNION
SELECT 'BalanceMissingOwnerId' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0C24 WHERE LD0V0C24.AGARNR = 0) AS Result UNION
SELECT 'BalanceMissingService' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0C24 WHERE NOT LD0V0C24.INSNR IN(SELECT LD0VYC20.INSNR FROM LD0VYC20)) AS Result UNION
SELECT 'BalanceMissingServiceId' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0C24 WHERE LD0V0C24.INSNR = 0) AS Result UNION
SELECT 'BalanceSpecialMissingOwner' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0C24 WHERE LD0V0C24.AGARTYP = 5 AND NOT LD0V0C24.AGARNR IN(SELECT LD0VYE.BIDRTFNR FROM LD0VYE)) AS Result UNION
SELECT 'BaseDecisionMissingInServiceConnection' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYE WHERE LD0VYE.INSNR = 0 AND LD0VYE.BESLUTNR IN(SELECT LD0VYC20.BESLUTNR FROM LD0VYC20)) AS Result UNION
SELECT 'BBICRelationCheckMissingPersonInPersonRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0V19 WHERE NOT EXISTS (SELECT 'X' FROM LD0V0A WHERE LD0V0A.PNR = LD0V0V19.PNR)) AS Result UNION
SELECT 'BonusChildWithMissingHousehold' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0K04 WHERE NOT EXISTS (SELECT 'X' FROM LD0V0K WHERE LD0V0K.HUSHLNR = LD0V0K04.HUSHLNR)) AS Result UNION
SELECT 'BonusChildWithMissingPerson' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0K04 WHERE NOT EXISTS (SELECT 'X' FROM LD0V0A WHERE LD0V0A.PNR = LD0V0K04.PNR)) AS Result UNION
SELECT 'CalculationExpence2MissingInCodetext ' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0D03 WHERE LD0V0D03.UTGNR2 > 0 AND LD0V0D03.UTGNR2 < 10000 AND NOT LD0V0D03.UTGNR2 IN(SELECT LD0V0Q01.KOD FROM LD0V0Q01 WHERE LD0V0Q01.KODTYP = 'UTGTYP')) AS Result UNION
SELECT 'CalculationExpenceMissingCalculation' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0D03 WHERE NOT LD0V0D03.BERAKNR IN(SELECT LD0VYD.BERAKNR FROM LD0VYD)) AS Result UNION
SELECT 'CalculationExpenceMissingInCodetext' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0D03 WHERE LD0V0D03.UTGNR > 0 AND LD0V0D03.UTGNR < 10000 AND NOT LD0V0D03.UTGNR IN(SELECT LD0V0Q01.KOD FROM LD0V0Q01 WHERE LD0V0Q01.KODTYP = 'UTGTYP')) AS Result UNION
SELECT 'CalculationHavingBothInvestigationAndService' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYD WHERE AEVERKNR > 0 AND INSNR > 0) AS Result UNION
SELECT 'CalculationIncome2MissingInCodetext' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0D02 WHERE LD0V0D02.INKNR2 > 0 AND LD0V0D02.INKNR2 < 10000 AND NOT LD0V0D02.INKNR2 IN(SELECT LD0V0Q01.KOD FROM LD0V0Q01 WHERE LD0V0Q01.KODTYP = 'INKTYP')) AS Result UNION
SELECT 'CalculationIncomeMissingCalculation' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0D02 WHERE NOT LD0V0D02.BERAKNR IN(SELECT LD0VYD.BERAKNR FROM LD0VYD)) AS Result UNION
SELECT 'CalculationIncomeMissingInCodetext' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0D02 WHERE LD0V0D02.INKNR > 0 AND LD0V0D02.INKNR < 10000 AND NOT LD0V0D02.INKNR IN(SELECT LD0V0Q01.KOD FROM LD0V0Q01 WHERE LD0V0Q01.KODTYP = 'INKTYP')) AS Result UNION
SELECT 'CalculationInInvestigationMissingInvestigation' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYD WHERE LD0VYD.AEVERKNR > 0 AND NOT EXISTS (SELECT 'X' FROM LD0VYC WHERE LD0VYC.AEVERKNR = LD0VYD.AEVERKNR)) AS Result UNION
SELECT 'CalculationInServiceMissingService' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYD WHERE LD0VYD.INSNR > 0 AND NOT EXISTS (SELECT 'X' FROM LD0VYC20 WHERE LD0VYC20.INSNR = LD0VYD.INSNR)) AS Result UNION
SELECT 'CalculationMissingAktualisering' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYD WHERE LD0VYD.AKTUALNR > 0 AND NOT EXISTS (SELECT 'X' FROM LD0VYH WHERE LD0VYH.AKTUALNR = LD0VYD.AKTUALNR)) AS Result UNION
SELECT 'CalculationMissingCalculationPersons' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYD WHERE SUMNORM > 0 AND NOT EXISTS (SELECT 'X' FROM LD0V0D01 WHERE LD0V0D01.BERAKNR = LD0VYD.BERAKNR)) AS Result UNION
SELECT 'CalculationMissingInvestigationAndService' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYD WHERE AEVERKNR = 0 AND INSNR = 0) AS Result UNION
SELECT 'CalculationMissingNorm' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYD WHERE LD0VYD.NORMNR = 0) AS Result UNION
SELECT 'CalculationNormMissingInNormRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYD WHERE NOT LD0VYD.NORMNR  IN(SELECT LD0V0D10.NORMNR FROM LD0V0D10)) AS Result UNION
SELECT 'CalculationPersonsMissingCalculation' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0D01 WHERE NOT LD0V0D01.BERAKNR IN(SELECT LD0VYD.BERAKNR FROM LD0VYD)) AS Result UNION
SELECT 'CalculationPersonsMissingInPersonRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0D01 WHERE NOT LD0V0D01.PNR IN(SELECT LD0V0A.PNR FROM LD0V0A)) AS Result UNION
SELECT 'CalculationSpecialExpence2MissingInCodetext' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0D04 WHERE LD0V0D04.SPECNR2 > 0 AND LD0V0D04.SPECNR2 < 10000 AND NOT LD0V0D04.SPECNR2 IN(SELECT LD0V0Q01.KOD FROM LD0V0Q01 WHERE LD0V0Q01.KODTYP = 'SPECTYP')) AS Result UNION
SELECT 'CalculationSpecialExpenceMissingCalculation' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0D04 WHERE NOT LD0V0D04.BERAKNR IN(SELECT LD0VYD.BERAKNR FROM LD0VYD)) AS Result UNION
SELECT 'CalculationSpecialExpenceMissingInCodetext' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0D04 WHERE LD0V0D04.SPECNR > 0 AND LD0V0D04.SPECNR < 10000 AND NOT LD0V0D04.SPECNR IN(SELECT LD0V0Q01.KOD FROM LD0V0Q01 WHERE LD0V0Q01.KODTYP = 'SPECTYP')) AS Result UNION
SELECT 'CalculationWrongPeriod' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYD WHERE FOMDAT = ' ' OR TOMDAT = ' ') AS Result UNION
SELECT 'CaseworkerAddressMissingInAddressRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0I WHERE LD0V0I.ADRKOD > ' ' AND NOT LD0V0I.ADRKOD = 'Borta' AND NOT EXISTS (SELECT 'X' FROM LD0V0I02 WHERE LD0V0I02.ADRKOD = LD0V0I.ADRKOD)) AS Result UNION
SELECT 'CaseworkerAddressSdnMissingInAddressRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0I WHERE LD0V0I.ADRKODSDN > ' ' AND NOT LD0V0I.ADRKODSDN = 'Borta' AND NOT EXISTS (SELECT 'X' FROM LD0V0I02 WHERE LD0V0I02.ADRKOD = LD0V0I.ADRKODSDN)) AS Result UNION
SELECT 'CaseworkerOrganisationMissingInCaseworkerRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0I01 WHERE NOT EXISTS (SELECT 'X' FROM LD0V0I WHERE LD0V0I.HAND = LD0V0I01.HAND)) AS Result UNION
SELECT 'CaseworkerOrganisationMissingInOrganisationRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0I01 WHERE NOT EXISTS (SELECT 'X' FROM LD0V0J01 WHERE LD0V0J01.ORGID = LD0V0I01.ORGID AND LD0V0J01.ORGENHNR = LD0V0I01.ORGENHNR)) AS Result UNION
SELECT 'CaseworkerOrganisationWithAddressMissingInAddressRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0I01 WHERE LD0V0I01.ADRKOD > ' ' AND NOT EXISTS (SELECT 'X' FROM LD0V0I02 WHERE LD0V0I02.ADRKOD = LD0V0I01.ADRKOD)) AS Result UNION
SELECT 'CaseworkerOrganisationWrongPeriod' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0I01 WHERE LD0V0I01.FOMDAT = ' ' OR LD0V0I01.TOMDAT = ' ') AS Result UNION
SELECT 'CaseworkerWrongPeriod' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0I WHERE LD0V0I.FOMDAT = ' ' OR LD0V0I.TOMDAT = ' ') AS Result UNION
SELECT 'ChainsMissingExecution' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYC10 WHERE LD0VYC10.VERKNR > 0 AND NOT LD0VYC10.VERKNR IN (SELECT LD0VYC.AEVERKNR FROM LD0VYC WHERE LD0VYC.TMARK = 1)) AS Result UNION
SELECT 'ChainsMissingInvestigation' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYC10 WHERE LD0VYC10.ARENDENR > 0 AND NOT LD0VYC10.ARENDENR IN (SELECT LD0VYC.AEVERKNR FROM LD0VYC WHERE LD0VYC.TMARK = 0)) AS Result UNION
SELECT 'ChainsMissingInvestigationAndExecution' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYC10 WHERE LD0VYC10.ARENDENR = 0 AND LD0VYC10.VERKNR = 0) AS Result UNION
SELECT 'ChainsMissingService' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYC10 WHERE LD0VYC10.INSNR > 0 AND NOT LD0VYC10.INSNR IN (SELECT LD0VYC20.INSNR FROM LD0VYC20)) AS Result UNION
SELECT 'ChainsWithWrongPersonId' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYC10 WHERE LD0VYC10.AKTPNR LIKE '%*%' OR LD0VYC10.AKTPNR = ' ') AS Result UNION
SELECT 'CodeTextHasNoName' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0Q01 WHERE KLARTEXT = '' AND KOD != 100113) AS Result UNION
SELECT 'CodeTextInvestigationTypeHasMissingDossierType' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0Q01 WHERE KODTYP = 'UTREDTYP' AND XNUM1 = 0) AS Result UNION
SELECT 'CodtextWithoutEntryInCodetypeTable' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0Q01 WHERE NOT EXISTS(SELECT 'X' FROM LD0V0Q WHERE LD0V0Q.KODTYP = LD0V0Q01.KODTYP)) AS Result UNION
SELECT 'CollectiveCopyFromCheckIfDocumentExists' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0T44 WHERE NOT EXISTS (SELECT 'X' FROM LD0V0T41 WHERE LD0V0T41.DOKUMENTNR = LD0V0T44.DOKNRFROM)) AS Result UNION
SELECT 'CollectiveCopyToCheckIfDocumentExists' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0T44 WHERE NOT EXISTS (SELECT 'X' FROM LD0V0T41 WHERE LD0V0T41.DOKUMENTNR = LD0V0T44.DOKNRTO)) AS Result UNION
SELECT 'CommunicationConnectedToCaseworkerMissingCaseworkerRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0H50 WHERE LD0V0H50.CASEWORKER > ' ' AND NOT EXISTS (SELECT 'X' FROM LD0V0I WHERE LD0V0I.HAND = LD0V0H50.CASEWORKER)) AS Result UNION
SELECT 'CommunicationMissingDocument' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0H50 WHERE NOT EXISTS (SELECT 'X' FROM LD0V0T41 WHERE LD0V0T41.DELETED = 0 AND LD0V0T41.DOKUMENTNR = LD0V0H50.DOCUMENTID)) AS Result UNION
SELECT 'ConcernReportExistForReportErrand' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0REPORTERRAND WHERE NOT EXISTS (SELECT 'X' FROM LD0V0CONCERNREPORTERRAND  WHERE LD0V0CONCERNREPORTERRAND.REPORTID = LD0V0REPORTERRAND.REPORTID)) AS Result UNION
SELECT 'ConsentConnectedToCaseworkerThatIsMissingInCaseworkerRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYH10 WHERE LD0VYH10.HAND1 > ' ' AND NOT EXISTS (SELECT 'X' FROM LD0V0I WHERE LD0V0I.HAND = LD0VYH10.HAND1)) AS Result UNION
SELECT 'ConsentConnectedToCoCaseworkerThatIsMissingInCaseworkerRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYH10 WHERE LD0VYH10.HAND2 > ' ' AND NOT EXISTS (SELECT 'X' FROM LD0V0I WHERE LD0V0I.HAND = LD0VYH10.HAND2)) AS Result UNION
SELECT 'ConsentConnectedToDossierThatIsMissingInDossierRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYH10 WHERE LD0VYH10.AKTNR > 0 AND NOT EXISTS (SELECT 'X' FROM LD0VYB WHERE LD0VYB.AKTNR = LD0VYH10.AKTNR)) AS Result UNION
SELECT 'ConsentConnectedToInvestigationThatIsMissingInInvestigationRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYH10 WHERE LD0VYH10.AEVERKNR > 0 AND NOT EXISTS (SELECT 'X' FROM LD0VYC WHERE LD0VYC.AEVERKNR = LD0VYH10.AEVERKNR)) AS Result UNION
SELECT 'ConsentConnectedToOrganisationThatIsMissingInOrganisationRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYH10 WHERE LD0VYH10.ORGENHNR > ' ' AND NOT EXISTS (SELECT 'X' FROM LD0V0J01 WHERE LD0V0J01.ORGID = LD0VYH10.ORGID AND LD0V0J01.ORGENHNR = LD0VYH10.ORGENHNR)) AS Result UNION
SELECT 'ConsentConnectedToServiceThatIsMissingInServiceRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYH10 WHERE LD0VYH10.INSNR > 0 AND NOT EXISTS (SELECT 'X' FROM LD0VYC20 WHERE LD0VYC20.INSNR = LD0VYH10.INSNR)) AS Result UNION
SELECT 'ConsentHasEmptyToDateWhenItShouldBe9999999' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT H10.GILTIGTOM FROM LD0V0H10 H10 WHERE H10.GILTIGTOM = '') AS Result UNION
SELECT 'ConsentMissingInDossierEventRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYH10 WHERE LD0VYH10.AKTNR > 0 AND NOT EXISTS (SELECT 'X' FROM LD0VYB01 WHERE LD0VYB01.HANDELSE = 70 AND LD0VYB01.HAGNR = LD0VYH10.SAMTNR)) AS Result UNION
SELECT 'ConsentWithoutConnection' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYH10 WHERE LD0VYH10.AKTNR = 0 AND LD0VYH10.AEVERKNR = 0 AND LD0VYH10.INSNR = 0) AS Result UNION
SELECT 'DecisionCodeMissingInDecisionCodeRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYE WHERE LD0VYE.BESLUT > 0 AND NOT EXISTS(SELECT 'X' FROM LD0V0Q01 WHERE LD0V0Q01.KODTYP = 'BESLUT' AND LD0V0Q01.KOD = LD0VYE.BESLUT)) AS Result UNION
SELECT 'DecisionCommunicationMissingDecision' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0E03 WHERE NOT LD0V0E03.BESLUTNR IN (SELECT LD0VYE.BESLUTNR FROM LD0VYE)) AS Result UNION
SELECT 'DecisionCommunicationMissingInPersonRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0E03 WHERE NOT LD0V0E03.PNR IN (SELECT LD0V0A.PNR FROM LD0V0A)) AS Result UNION
SELECT 'DecisionDecisionmakerMissingInRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYE WHERE LD0VYE.BESLTYP != 12 AND NOT EXISTS (SELECT 'X' FROM LD0V0I WHERE LD0V0I.HAND = LD0VYE.BESFATT)) AS Result UNION
SELECT 'DecisionInInvestigationMissingInInvestigationRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYE WHERE LD0VYE.AEVERKNR > 0 AND NOT LD0VYE.AEVERKNR IN(SELECT LD0VYC.AEVERKNR FROM LD0VYC)) AS Result UNION
SELECT 'DecisionInServiceMissingInServiceRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYE WHERE LD0VYE.INSNR > 0 AND NOT LD0VYE.INSNR IN(SELECT LD0VYC20.INSNR FROM LD0VYC20)) AS Result UNION
SELECT 'DecisionMessageMissingDecision' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0E10 WHERE NOT EXISTS (SELECT 'X' FROM LD0VYE WHERE LD0VYE.BESLUTNR = LD0V0E10.BESLUTNR)) AS Result UNION
SELECT 'DecisionMissingAktualisering' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYE WHERE LD0VYE.AKTUALNR > 0 AND NOT EXISTS (SELECT 'X' FROM LD0VYH WHERE LD0VYH.AKTUALNR = LD0VYE.AKTUALNR)) AS Result UNION
SELECT 'DecisionMissingConnections' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYE WHERE AEVERKNR = 0 AND INSNR = 0 AND NOT BESLTYP = 6 AND MAKDAT = ' ') AS Result UNION
SELECT 'DecisionMissingDecisionCode' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYE WHERE BESLUT = 0) AS Result UNION
SELECT 'DecisionMissingDecisionPersons' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYE WHERE NOT BESLTYP = 6 AND MAKDAT = ' ' AND NOT EXISTS (SELECT 'X' FROM LD0V0E01 WHERE LD0V0E01.BESLUTNR = LD0VYE.BESLUTNR)) AS Result UNION
SELECT 'DecisionNotStartInvestigationMissingAktualisering' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYE WHERE LD0VYE.BESLTYP = 6 AND NOT EXISTS (SELECT 'X' FROM LD0VYH WHERE LD0VYH.BESLUTNR = LD0VYE.BESLUTNR)) AS Result UNION
SELECT 'DecisionNotStartInvestigationMissingInAktualisering' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYE WHERE LD0VYE.BESLTYP = 6 AND NOT EXISTS (SELECT 'X' FROM LD0VYH WHERE LD0VYH.BESLUTNR = LD0VYE.BESLUTNR)) AS Result UNION
SELECT 'DecisionOrganisationMissingInRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYE WHERE LD0VYE.ORGENHNR > ' ' AND NOT EXISTS (SELECT 'X' FROM LD0V0J01 WHERE LD0V0J01.ORGID = LD0VYE.ORGID AND LD0V0J01.ORGENHNR = LD0VYE.ORGENHNR)) AS Result UNION
SELECT 'DecisionPartsMissingDecision' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0E05 WHERE NOT LD0V0E05.BESLUTNR IN (SELECT LD0VYE.BESLUTNR FROM LD0VYE)) AS Result UNION
SELECT 'DecisionPartsMissingInPartRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0E05 WHERE NOT LD0V0E05.REFPNR IN (SELECT LD0V0Y.REFPNR FROM LD0V0Y)) AS Result UNION
SELECT 'DecisionPersonsMissingDecision' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0E01 WHERE NOT EXISTS (SELECT 'X' FROM LD0VYE WHERE LD0VYE.BESLUTNR = LD0V0E01.BESLUTNR)) AS Result UNION
SELECT 'DecisionPersonsMissingInPersonRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0E01 WHERE NOT LD0V0E01.PNR IN (SELECT LD0V0A.PNR FROM LD0V0A)) AS Result UNION
SELECT 'DecisionProposalMessageMissingProposal' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0ProposalMessage WHERE PROPOSALID > 0 AND NOT EXISTS (SELECT 'X' FROM LD0V0DecisionProposal WHERE LD0V0DecisionProposal.PROPOSALID = LD0V0ProposalMessage.PROPOSALID)) AS Result UNION
SELECT 'DecisionTypeMissingInDecisionTypeRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYE WHERE NOT EXISTS(SELECT 'X' FROM LD0V0Q01 WHERE LD0V0Q01.KODTYP = 'BESLUTTYP' AND LD0V0Q01.KOD = LD0VYE.BESLTYP)) AS Result UNION
SELECT 'DecisionWrongDates' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYE WHERE NOT LD0VYE.DATUM LIKE '19%' AND NOT LD0VYE.DATUM LIKE '20%') AS Result UNION
SELECT 'DecisionWrongPeriod' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYE WHERE FOMDAT = ' ' OR TOMDAT = ' ') AS Result UNION
SELECT 'DocumentPdfTMissingAktualisering' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0T43 WHERE AGARTYP = 7040 AND NOT EXISTS (SELECT 'X' FROM LD0VYH WHERE LD0VYH.AKTUALNR = LD0V0T43.AGARNR)) AS Result UNION
SELECT 'DocumentPdfTMissingExecution' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0T43 WHERE AGARTYP = 7025 AND NOT EXISTS (SELECT 'X' FROM LD0VYC WHERE LD0VYC.AEVERKNR = LD0V0T43.AGARNR)) AS Result UNION
SELECT 'DocumentPdfTMissingInvestigation' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0T43 WHERE AGARTYP = 7017 AND NOT EXISTS (SELECT 'X' FROM LD0VYC WHERE LD0VYC.AEVERKNR = LD0V0T43.AGARNR)) AS Result UNION
SELECT 'DocumentPdfTMissingService' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0T43 WHERE AGARTYP = 7083 AND NOT EXISTS (SELECT 'X' FROM LD0VYC20 WHERE LD0VYC20.INSNR = LD0V0T43.AGARNR)) AS Result UNION
SELECT 'DocumentsMissingCodeText' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0T41 WHERE LD0V0T41.DOKTYP > 0 AND NOT EXISTS (SELECT 'X' FROM LD0V0Q01 WHERE LD0V0Q01.KODTYP = 'TYPDOK' AND LD0V0Q01.KOD = LD0V0T41.DOKTYP) AND LD0V0T41.DOKUMENTNR > 21700) AS Result UNION
SELECT 'DocumentsWithOutPnrMissingInResourceRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0T41 WHERE LD0V0T41.DELETED = 0 AND LD0V0T41.PERSONNR = ' '  AND AGARTYP = 38 AND NOT EXISTS (SELECT 'X' FROM LD0V0L WHERE LD0V0L.PNR = LD0V0T41.PERSONNR AND LD0V0L.RESURSNR = LD0V0T41.AGARNR)) AS Result UNION
SELECT 'DocumentsWithPnrMissingInPersonRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0T41 WHERE LD0V0T41.DELETED = 0 AND LD0V0T41.PERSONNR > ' ' AND AGARTYP != 38 AND NOT EXISTS (SELECT 'X' FROM LD0V0A WHERE LD0V0A.PNR = LD0V0T41.PERSONNR) AND LD0V0T41.DOKUMENTNR > 24330) AS Result UNION
SELECT 'DocumentsWithPnrMissingInResourceRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0T41 WHERE LD0V0T41.DELETED = 0 AND LD0V0T41.PERSONNR > ' '  AND AGARTYP = 38 AND NOT EXISTS (SELECT 'X' FROM LD0V0L WHERE LD0V0L.PNR = LD0V0T41.PERSONNR AND LD0V0L.RESURSNR = LD0V0T41.AGARNR)) AS Result UNION
SELECT 'DocumentT41AssignmentIfoPartMissingDocumentT41' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0T411 WHERE NOT EXISTS (SELECT 'X' FROM LD0V0T41 WHERE LD0V0T41.DOKUMENTNR = LD0V0T411.DOKUMENTNR)) AS Result UNION
SELECT 'DocumentType10MissingOwner' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0T40 WHERE LD0V0T40.DOKTYP = 10 AND NOT EXISTS (SELECT 'X' FROM LD0VYC WHERE LD0VYC.AEVERKNR = LD0V0T40.AEVERKNR)) AS Result UNION
SELECT 'DocumentType11MissingOwner' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0T40 WHERE LD0V0T40.DOKTYP = 11 AND NOT EXISTS (SELECT 'X' FROM LD0V0A700 WHERE LD0V0A700.FLYKTNR = LD0V0T40.AGARNR)) AS Result UNION
SELECT 'DocumentType14MissingOwner' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0T40 WHERE LD0V0T40.DOKTYP = 14 AND NOT EXISTS (SELECT 'X' FROM LD0VYH WHERE LD0VYH.AKTUALNR = LD0V0T40.AGARNR)) AS Result UNION
SELECT 'DocumentType1MissingOwner ' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0T40 WHERE LD0V0T40.DOKTYP = 1 AND NOT EXISTS (SELECT 'X' FROM LD0VYC WHERE LD0VYC.AEVERKNR = LD0V0T40.AEVERKNR)) AS Result UNION
SELECT 'DocumentType20MissingOwner' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0T41 WHERE LD0V0T41.AGARTYP = 20 AND DELETED = 0 AND NOT EXISTS (SELECT 'X' FROM LD0VYH WHERE LD0VYH.AKTUALNR = LD0V0T41.AGARNR) AND DOKUMENTNR > 22696) AS Result UNION
SELECT 'DocumentType21MissingOwner' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0T41 WHERE LD0V0T41.AGARTYP = 21 AND DELETED = 0 AND NOT EXISTS (SELECT 'X' FROM LD0VYC WHERE LD0VYC.AEVERKNR = LD0V0T41.AGARNR) AND DOKUMENTNR > 22351) AS Result UNION
SELECT 'DocumentType22MissingOwner' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0T41 WHERE LD0V0T41.AGARTYP = 22 AND DELETED = 0 AND NOT EXISTS (SELECT 'X' FROM LD0VYC WHERE LD0VYC.AEVERKNR = LD0V0T41.AGARNR)) AS Result UNION
SELECT 'DocumentType23MissingOwner' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0T41 WHERE LD0V0T41.AGARTYP = 23 AND DELETED = 0 AND NOT EXISTS (SELECT 'X' FROM LD0VYC20 WHERE LD0VYC20.INSNR = LD0V0T41.AGARNR) AND DOKUMENTNR > 23953) AS Result UNION
SELECT 'DocumentType2MissingOwner ' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0T40 WHERE LD0V0T40.DOKTYP = 2 AND NOT EXISTS (SELECT 'X' FROM LD0VYE WHERE LD0VYE.BESLUTNR = LD0V0T40.AGARNR)) AS Result UNION
SELECT 'DocumentType30MissingOwner' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0T41 WHERE LD0V0T41.AGARTYP = 30 AND DELETED = 0 AND NOT EXISTS (SELECT 'X' FROM LD0VYU10 WHERE LD0VYU10.INSKRIVNINGSNR = LD0V0T41.AGARNR)) AS Result UNION
SELECT 'DocumentType31MissingOwner' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0T41 WHERE LD0V0T41.AGARTYP = 31 AND DELETED = 0 AND NOT EXISTS (SELECT 'X' FROM LD0VYU40 WHERE LD0VYU40.KONTAKTTILLFNR = LD0V0T41.AGARNR)) AS Result UNION
SELECT 'DocumentType32MissingOwner' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0T41 WHERE LD0V0T41.AGARTYP = 32 AND DELETED = 0 AND NOT EXISTS (SELECT 'X' FROM LD0VYU30 WHERE LD0VYU30.PLANNR = LD0V0T41.AGARNR)) AS Result UNION
SELECT 'DocumentType33MissingOwner' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0T41 WHERE LD0V0T41.AGARTYP = 33 AND DELETED = 0 AND NOT EXISTS (SELECT 'X' FROM LD0V0U60 WHERE LD0V0U60.PRAKPROJNR = LD0V0T41.AGARNR)) AS Result UNION
SELECT 'DocumentType34MissingOwner' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0T41 WHERE LD0V0T41.AGARTYP = 34 AND DELETED = 0 AND NOT EXISTS (SELECT 'X' FROM LD0V0U61 WHERE LD0V0U61.PRAKPROJNR = LD0V0T41.AGARNR)) AS Result UNION
SELECT 'DocumentType35MissingOwner' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0T41 WHERE LD0V0T41.AGARTYP = 35 AND DELETED = 0 AND NOT EXISTS (SELECT 'X' FROM LD0V0U60 WHERE LD0V0U60.PRAKPROJNR = LD0V0T41.AGARNR)) AS Result UNION
SELECT 'DocumentType36MissingOwner1 ' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0T41 WHERE LD0V0T41.AGARTYP = 36 AND DELETED = 0 AND NOT EXISTS (SELECT 'X' FROM LD0V0U61 WHERE LD0V0U61.PRAKPROJNR = LD0V0T41.AGARNR)) AS Result UNION
SELECT 'DocumentType41MissingOwner' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0T41 WHERE LD0V0T41.AGARTYP = 41 AND DELETED = 0 AND NOT EXISTS (SELECT 'X' FROM LD0VYC20 WHERE LD0VYC20.INSNR = LD0V0T41.AGARNR) AND DOKUMENTNR > 23146) AS Result UNION
SELECT 'DocumentType42MissingOwner' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0T41 WHERE LD0V0T41.AGARTYP = 42 AND DELETED = 0 AND NOT EXISTS (SELECT 'X' FROM LD0VYC WHERE LD0VYC.AEVERKNR = LD0V0T41.AGARNR) AND DOKUMENTNR > 23166) AS Result UNION
SELECT 'DocumentType45MissingOwner' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0T41 WHERE LD0V0T41.AGARTYP = 45 AND DELETED = 0 AND NOT EXISTS (SELECT 'X' FROM LD0VYB WHERE LD0VYB.AKTNR = LD0V0T41.AGARNR)) AS Result UNION
SELECT 'DocumentType50MissingOwner' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0T41 WHERE LD0V0T41.AGARTYP = 50 AND DELETED = 0 AND NOT EXISTS (SELECT 'X' FROM LD0VYB WHERE LD0VYB.AKTNR = LD0V0T41.AGARNR)) AS Result UNION
SELECT 'DocumentType51MissingOwner' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0T41 WHERE LD0V0T41.AGARTYP = 51 AND DELETED = 0 AND NOT EXISTS (SELECT 'X' FROM LD0VYC WHERE LD0VYC.AEVERKNR = LD0V0T41.AGARNR)) AS Result UNION
SELECT 'DocumentType52MissingOwner' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0T41 WHERE LD0V0T41.AGARTYP = 52 AND DELETED = 0 AND NOT EXISTS (SELECT 'X' FROM LD0VYC WHERE LD0VYC.AEVERKNR = LD0V0T41.AGARNR)) AS Result UNION
SELECT 'DocumentType53MissingOwner' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0T41 WHERE LD0V0T41.AGARTYP = 53 AND DELETED = 0 AND NOT EXISTS (SELECT 'X' FROM LD0VYC20 WHERE LD0VYC20.INSNR = LD0V0T41.AGARNR)) AS Result UNION
SELECT 'DocumentType62MissingOwner' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0T41 WHERE LD0V0T41.AGARTYP = 62 AND DELETED = 0 AND NOT EXISTS (SELECT 'X' FROM LD0V0U01 WHERE LD0V0U01.KARTLAGGNR = LD0V0T41.AGARNR)) AS Result UNION
SELECT 'DocumentType7MissingOwner ' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0T40 WHERE LD0V0T40.DOKTYP = 7 AND NOT EXISTS (SELECT 'X' FROM LD0VYC20 WHERE LD0VYC20.INSNR = LD0V0T40.INSNR)) AS Result UNION
SELECT 'DocumentTypeAssignmentIFOMissingOwner' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0T41 T41 WHERE T41.AGARTYP = 63 AND DELETED = 0 AND NOT EXISTS (SELECT 'X' FROM LD0VYN900 N900 WHERE N900.UPPDRAGIFONR = T41.AGARNR)) AS Result UNION
SELECT 'DocumentTypeAssignmentMissingOwner' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0T41 T41 WHERE T41.AGARTYP = 46 AND DELETED = 0 AND NOT EXISTS (SELECT 'X' FROM LD0VYN90 N90 WHERE N90.UPPDRAGNR = T41.AGARNR)) AS Result UNION
SELECT 'DossierDocumentMissingDossierEvent' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0T41 WHERE LD0V0T41.AGARTYP = 39 AND LD0V0T41.DELETED = 0 AND NOT EXISTS (SELECT 'X' FROM LD0VYB01 WHERE LD0VYB01.HTYP = 859 AND LD0VYB01.HAGNR = LD0V0T41.DOKUMENTNR) AND LD0V0T41.DOKUMENTNR > 20000) AS Result UNION
SELECT 'DossierEventMissingDossier' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYB01 WHERE LD0VYB01.HTYP = 856 AND NOT EXISTS (SELECT 'X' FROM LD0VYB WHERE LD0VYB.AKTNR = LD0VYB01.HAGNR) ) AS Result UNION
SELECT 'DossierEventsMissingAktualisering' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYB01 WHERE LD0VYB01.HTYP = 30 AND NOT EXISTS (SELECT 'X' FROM LD0VYH WHERE LD0VYH.AKTUALNR = LD0VYB01.HAGNR)) AS Result UNION
SELECT 'DossierEventsMissingConsent' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYB01 WHERE LD0VYB01.HTYP = 70 AND NOT EXISTS (SELECT 'X' FROM LD0VYH10 WHERE LD0VYH10.SAMTNR = LD0VYB01.HAGNR)) AS Result UNION
SELECT 'DossierEventsMissingDateOrTime' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYB01 WHERE TID = ' ' OR UPDDAT = ' ') AS Result UNION
SELECT 'DossierEventsMissingDocument' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYB01 WHERE LD0VYB01.HTYP = 859 AND NOT EXISTS (SELECT 'X' FROM LD0V0T41 WHERE LD0V0T41.AGARTYP = 39 AND LD0V0T41.DELETED = 0 AND LD0V0T41.DOKUMENTNR = LD0VYB01.HAGNR) AND LD0VYB01.HAGNR > 20000) AS Result UNION
SELECT 'DossierEventsMissingDocumentPdf' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYB01 WHERE LD0VYB01.HTYP = 350 AND NOT EXISTS (SELECT 'X' FROM LD0V0T43 WHERE LD0V0T43.INFOGANR = LD0VYB01.HAGNR)) AS Result UNION
SELECT 'DossierEventsMissingDossier' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYB01 WHERE NOT AKTNR IN(SELECT AKTNR FROM LD0VYB)) AS Result UNION
SELECT 'DossierEventsMissingEventText' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYB01 WHERE HTEXT1 = ' ') AS Result UNION
SELECT 'DossierMissingDossierEvents' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYB WHERE NOT EXISTS (SELECT 'X' FROM LD0VYB01 WHERE LD0VYB01.HTYP = 856 AND LD0VYB01.HAGNR = LD0VYB.AKTNR)) AS Result UNION
SELECT 'DossierPersonMissingInPersonRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYB WHERE NOT EXISTS (SELECT 'X' FROM LD0V0A WHERE LD0V0A.PNR = LD0VYB.AKTPNR)) AS Result UNION
SELECT 'DossierWithoutArchive' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYB WHERE ARKIVNR = 0) AS Result UNION
SELECT 'DossierWithoutInvestigationOrExecution' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYB WHERE NOT EXISTS (SELECT 'X' FROM LD0VYC WHERE LD0VYC.AKTNR = LD0VYB.AKTNR)) AS Result UNION
SELECT 'DossierWithoutPersonId' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYB WHERE AKTPNR = ' ') AS Result UNION
SELECT 'DossierWithoutType' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYB WHERE TYPNR = 0) AS Result UNION
SELECT 'DossierWithWrongPersonId' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYB WHERE AKTPNR LIKE '%*%' OR AKTPNR = ' ') AS Result UNION
SELECT 'DUAActivityHasValidConnectionToEnrollmentPlan' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0UDUAA DUAA WHERE EXISTS(SELECT 'X' FROM LD0VYU30 U30 WHERE DUAA.PLANNR = U30.PLANNR AND DUAA.VERSIONNR = U30.VERSIONNR AND DUAA.INSKRIVNINGSNR != U30.INSKRIVNINGSNR )) AS Result UNION
SELECT 'DUAResultHasConnectionToDUAActivityOrEnrollmentPlanActivity' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0UDUAR DUAR WHERE (NOT EXISTS(SELECT 'X' FROM LD0V0U34 U34 WHERE U34.PLANAKTIVITETNR = DUAR.PLANAKTIVITETNR) AND NOT EXISTS(SELECT 'X' FROM LD0V0UDUAA DUAA WHERE DUAA.PLANAKTIVITETNR = DUAR.PLANAKTIVITETNR))) AS Result UNION
SELECT 'DUAActivityHasValidConnectionToEnrollmentPlanActivity' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0UDUAA DUAA WHERE EXISTS (SELECT 'X' FROM LD0VYU34 U34 WHERE DUAA.PLANAKTIVITETNR = U34.PLANAKTIVITETNR AND (DUAA.INTROARB != U34.INTROARB OR DUAA.AKTIVITET != U34.AKTIVITET OR DUAA.PLANNR != U34.PLANNR) )) AS Result UNION
SELECT 'DUAResultMissingCodeText' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0UDUAR DUAR WHERE NOT EXISTS (SELECT 'X' FROM LD0V0Q01 Q01 WHERE Q01.KODTYP = 'LNDUARES' AND Q01.KOD = DUAR.RESULTATKOD)) AS Result UNION
SELECT 'DUAResultMissingDateOrTime' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0UDUAR UDUAR WHERE UDUAR.TRANSDATUM = ' ') AS Result UNION
SELECT 'DUAResultMissingStatusCode' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0UDUAR DUAR WHERE DUAR.STATUS NOT BETWEEN 1 AND 3) AS Result UNION
SELECT 'DUAServiceMissingCodeText' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0UDUAI DUAI WHERE NOT EXISTS (SELECT 'X' FROM LD0V0Q01 Q01 WHERE Q01.KODTYP = 'LNDUAINS' AND Q01.KOD = DUAI.INSATSKOD)) AS Result UNION
SELECT 'DUAServiceMissingDateOrTime' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0UDUAI UDUAI WHERE UDUAI.TRANSDATUM = ' ') AS Result UNION
SELECT 'DUAServiceMissingStatusCode' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0UDUAI DUAI WHERE DUAI.STATUS NOT BETWEEN 1 AND 3) AS Result UNION
SELECT 'DuplicatedApplications' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYH WHERE NOT LD0VYH.APPLICATIONID = ' ' AND EXISTS (SELECT 'X' FROM LD0VAA0Aktualisering WHERE LD0VYH.APPLICATIONID = LD0VAA0Aktualisering.APPLICATIONID AND NOT LD0VYH.AKTUALNR = LD0VAA0Aktualisering.AKTUALNR )) AS Result UNION
SELECT 'EconomicalUnitMissingConnection' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0F11 WHERE NOT EXISTS (SELECT 'X' FROM LD0V0F10 WHERE LD0V0F10.EKENHNR = LD0V0F11.EKENHNR)) AS Result UNION
SELECT 'EconomicalUnitMissingConnectionToOrganisation' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0F11 WHERE NOT EXISTS (SELECT 'X' FROM LD0V0J01 WHERE LD0V0J01.ORGID = LD0V0F11.ORGID AND LD0V0J01.ORGENHNR = LD0V0F11.ORGENHNR)) AS Result UNION
SELECT 'EconomicalUnitPaymentRulesMissingConnection' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0F12 WHERE NOT EXISTS (SELECT 'X' FROM LD0V0F10 WHERE LD0V0F10.EKENHNR = LD0V0F12.EKENHNR)) AS Result UNION
SELECT 'EconomicalUnitWrongPeriod' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0F10 WHERE FOMDAT = ' ' OR TOMDAT = ' ') AS Result UNION
SELECT 'EnrollmentCaseworkerLogHasConnectionToEnrollment' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0U140 WHERE LD0V0U140.INSKRIVNINGSNR > 0 AND NOT EXISTS(SELECT 'X' FROM LD0VYU10 WHERE LD0VYU10.INSKRIVNINGSNR = LD0V0U140.INSKRIVNINGSNR)) AS Result UNION
SELECT 'EnrollmentContactEventHasConnectionToEnrollment' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYU40 WHERE LD0VYU40.INSKRIVNINGSNR >= 0 AND NOT EXISTS(SELECT 'X' FROM LD0VYU10 WHERE LD0VYU10.INSKRIVNINGSNR = LD0VYU40.INSKRIVNINGSNR)) AS Result UNION
SELECT 'EnrollmentContactPersonHasConnectionToEnrollment' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYU42 WHERE LD0VYU42.INSKRIVNINGSNR >= 0 AND NOT EXISTS(SELECT 'X' FROM LD0VYU10 WHERE LD0VYU10.INSKRIVNINGSNR = LD0VYU42.INSKRIVNINGSNR)) AS Result UNION
SELECT 'EnrollmentDirectiveHasConnectionToEnrollment' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0U11 WHERE LD0V0U11.INSKRIVNINGSNR >= 0 AND NOT EXISTS(SELECT 'X' FROM LD0VYU10 WHERE LD0VYU10.INSKRIVNINGSNR = LD0V0U11.INSKRIVNINGSNR)) AS Result UNION
SELECT 'EnrollmentDirectiveHasCorrectDates' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0U11 WHERE LD0V0U11.FROMDAT = '' OR LD0V0U11.FROMDAT = '99999999' OR LD0V0U11.TOMDAT = '') AS Result UNION
SELECT 'EnrollmentExistsForEnrollmentObjective' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0UMS WHERE MALSATTOBJEKTID = 7405 AND NOT EXISTS (SELECT 'X' FROM LD0VYU10 WHERE LD0VYU10.INSKRIVNINGSNR = LD0V0UMS.MALSATTOBJEKTNR)) AS Result UNION
SELECT 'EnrollmentHasCorrectDates' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYU10 WHERE LD0VYU10.INLEDDAT = '' OR LD0VYU10.INLEDDAT = '99999999' OR LD0VYU10.AVSLUTDAT = '') AS Result UNION
SELECT 'EnrollmentInterpreterOrderHasConnectionToEnrollmentContactEvent' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYU41 WHERE LD0VYU41.KONTAKTTILLFNR >= 0 AND NOT EXISTS(SELECT 'X' FROM LD0VYU40 WHERE LD0VYU40.KONTAKTTILLFNR = LD0VYU41.KONTAKTTILLFNR)) AS Result UNION
SELECT 'EnrollmentMissingDirective' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYU10 WHERE LD0VYU10.AVSLUTDAT = '99999999' AND NOT EXISTS (SELECT 'X' FROM LD0V0U11 WHERE LD0VYU10.INSKRIVNINGSNR = LD0V0U11.INSKRIVNINGSNR)) AS Result UNION
SELECT 'EnrollmentMissingPerson' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYU10 WHERE NOT EXISTS (SELECT 'X' FROM LD0VYA WHERE LD0VYA.PNR = LD0VYU10.PERSONNR)) AS Result UNION
SELECT 'EnrollmentMissingResponsible' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYU10 WHERE LD0VYU10.AVSLUTDAT = '99999999' AND NOT EXISTS (SELECT 'X' FROM LD0V0U12 WHERE LD0VYU10.INSKRIVNINGSNR = LD0V0U12.INSKRIVNINGSNR)) AS Result UNION
SELECT 'EnrollmentObjectiveExistsForReview' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0UMU WHERE NOT EXISTS (SELECT 'X' FROM LD0V0UMS  WHERE LD0V0UMS.MALSATTNR = LD0V0UMU.MALSATTNR)) AS Result UNION
SELECT 'EnrollmentObjectiveHasConnectionObjectId' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0UMS WHERE LD0V0UMS.MALSATTOBJEKTID = 0 ) AS Result UNION
SELECT 'EnrollmentObjectiveHasConnectionToEnrollment' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0UMS WHERE LD0V0UMS.MALSATTOBJEKTID = 7405 AND NOT EXISTS(SELECT 'X' FROM LD0VYU10 WHERE LD0VYU10.INSKRIVNINGSNR = LD0V0UMS.MALSATTOBJEKTNR)) AS Result UNION
SELECT 'EnrollmentObjectiveHasConnectionToEnrollmentPlan' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0UMS WHERE LD0V0UMS.MALSATTOBJEKTID = 7412 AND NOT EXISTS(SELECT 'X' FROM LD0VYU30 WHERE LD0VYU30.PLANNR = LD0V0UMS.MALSATTOBJEKTNR)) AS Result UNION
SELECT 'EnrollmentObjectiveHasConnectionToEnrollmentPlanActivity' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0UMS WHERE LD0V0UMS.MALSATTOBJEKTID = 7441 AND NOT EXISTS(SELECT 'X' FROM LD0VYU34 WHERE LD0VYU34.PLANAKTIVITETNR = LD0V0UMS.MALSATTOBJEKTNR)) AS Result UNION
SELECT 'EnrollmentObjectiveReviewHasConnectionToEnrollmentObjective' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0UMU WHERE LD0V0UMU.MALSATTNR >= 0 AND NOT EXISTS(SELECT 'X' FROM LD0V0UMS WHERE LD0V0UMU.MALSATTNR = LD0V0UMS.MALSATTNR)) AS Result UNION
SELECT 'EnrollmentPlanActivityExistsForEnrollmentObjective' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0UMS WHERE MALSATTOBJEKTID = 7441 AND NOT EXISTS (SELECT 'X' FROM LD0VYU34 WHERE LD0VYU34.PLANAKTIVITETNR = LD0V0UMS.MALSATTOBJEKTNR)) AS Result UNION
SELECT 'EnrollmentPlanActivityHasConnectionToActivityGroup' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYU34 WHERE LD0VYU34.GRUPPNR > 0 AND NOT EXISTS(SELECT 'X' FROM LD0VYU72 WHERE LD0VYU72.GRUPPNR = LD0VYU34.GRUPPNR)) AS Result UNION
SELECT 'EnrollmentPlanActivityHasConnectionToActivityOtherType' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYU34 WHERE LD0VYU34.OVRIGPLATS > 0 AND NOT EXISTS(SELECT 'X' FROM LD0V0Q01 WHERE LD0V0Q01.KODTYP = 'LNOVRPLATS' AND LD0VYU34.OVRIGPLATS = LD0V0Q01.KOD)) AS Result UNION
SELECT 'EnrollmentPlanActivityHasConnectionToEnrollmentPlan' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYU34 WHERE LD0VYU34.PLANNR >= 0 AND NOT EXISTS(SELECT 'X' FROM LD0VYU30 WHERE LD0VYU30.PLANNR = LD0VYU34.PLANNR AND LD0VYU30.VERSIONNR = LD0VYU34.VERSIONNR)) AS Result UNION
SELECT 'EnrollmentPlanActivityHasConnectionToSimplePlace' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYU34 WHERE LD0VYU34.ENKELPLATSNR > 0 AND NOT EXISTS(SELECT 'X' FROM LD0V0U70 WHERE LD0V0U70.ENKELPLATSNR = LD0VYU34.ENKELPLATSNR)) AS Result UNION
SELECT 'EnrollmentPlanActivityHasCorrectDates' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYU34 WHERE LD0VYU34.ANMALDAT = '' OR LD0VYU34.ANMALDAT = '99999999' OR LD0VYU34.PLANSTART = '' OR LD0VYU34.PLANSTART = '99999999' OR LD0VYU34.PLANSLUT = ''  OR LD0VYU34.VERKSTART = '' OR LD0VYU34.VERKSTART = '99999999' OR LD0VYU34.VERKSLUT = '') AS Result UNION
SELECT 'EnrollmentPlanActivityQueuePlaceShouldNotHaveSimplaplaceId' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYU34 U34 WHERE U34.INTROARB = 2 AND U34.ENKELPLATSNR > 0 AND EXISTS(SELECT 'X' FROM LD0V0U35 U35 WHERE U35.PLANAKTIVITETNR = U34.PLANAKTIVITETNR)) AS Result UNION
SELECT 'EnrollmentPlanActivitySimplePlaceIdShouldNotHaveOtherPlaceId' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYU34 U34 WHERE U34.INTROARB != 3 AND U34.ENKELPLATSNR > 0 AND EXISTS (SELECT 'X' FROM LD0V0U70 U70 WHERE U70.ENKELPLATSNR = U34.ENKELPLATSNR) AND (U34.OVRIGPLATS > 0 OR U34.GRUPPNR > 0 )) AS Result UNION
SELECT 'EnrollmentPlanActivitySimplePlaceWithWrongIntroarbValue' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYU34 U34 WHERE U34.INTROARB != 3 AND U34.ENKELPLATSNR > 0 AND NOT EXISTS (SELECT 'X' FROM LD0v0U35 U35 WHERE U35.PLANAKTIVITETNR = U34.PLANAKTIVITETNR) AND EXISTS (SELECT 'X' FROM LD0V0U70 U70 WHERE U70.ENKELPLATSNR = U34.ENKELPLATSNR)) AS Result UNION
SELECT 'EnrollmentPlanCaseworkerLogHasConnectionToEnrollmentPlan' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0U142 WHERE LD0V0U142.PLANNR > 0 AND NOT EXISTS(SELECT 'X' FROM LD0VYU30 WHERE LD0VYU30.PLANNR = LD0V0U142.PLANNR)) AS Result UNION
SELECT 'EnrollmentPlanExistsForEnrollmentObjective' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0UMS WHERE MALSATTOBJEKTID = 7412 AND NOT EXISTS (SELECT 'X' FROM LD0VYU30 WHERE LD0VYU30.PLANNR = LD0V0UMS.MALSATTOBJEKTNR)) AS Result UNION
SELECT 'EnrollmentPlanHasConnectionToEnrollment' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYU30 WHERE LD0VYU30.INSKRIVNINGSNR >= 0 AND NOT EXISTS(SELECT 'X' FROM LD0VYU10 WHERE LD0VYU10.INSKRIVNINGSNR = LD0VYU30.INSKRIVNINGSNR)) AS Result UNION
SELECT 'EnrollmentPlanHasCorrectDates' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYU30 WHERE LD0VYU30.FROMDAT = '' OR LD0VYU30.FROMDAT = '99999999' OR LD0VYU30.TOMDAT = '') AS Result UNION
SELECT 'EnrollmentResponsibleHasConnectionToEnrollment' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0U12 WHERE LD0V0U12.INSKRIVNINGSNR >= 0 AND NOT EXISTS(SELECT 'X' FROM LD0VYU10 WHERE LD0VYU10.INSKRIVNINGSNR = LD0V0U12.INSKRIVNINGSNR)) AS Result UNION
SELECT 'EntrysInQ03Step2WithoutAnyEntryInQ01' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0Q03 WHERE NOT EXISTS(SELECT 'X' FROM LD0V0Q WHERE LD0V0Q.KODTYP = LD0V0Q03.KODTYP2)) AS Result UNION
SELECT 'EntrysInQ03WithoutAnyEntryInQ01' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0Q03 WHERE NOT EXISTS(SELECT 'X' FROM LD0V0Q WHERE LD0V0Q.KODTYP = LD0V0Q03.KODTYP)) AS Result UNION
SELECT 'EntrysInQ20WithBlankStartAndEndDate' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0Q20 WHERE FOMDAT = ' ' OR TOMDAT = ' '  ) AS Result UNION
SELECT 'ExecutionsWithoutChain' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYC WHERE LD0VYC.TMARK = 1 AND NOT EXISTS (SELECT 'X' FROM LD0VYC10 WHERE LD0VYC10.VERKNR = LD0VYC.AEVERKNR)) AS Result UNION
SELECT 'FatherhoodIncomingErrandMissingAktualisering' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0E50 E50 WHERE E50.AKTUALNR > 0 AND NOT EXISTS(SELECT 'X' FROM LD0VYH H WHERE E50.AKTUALNR = H.AKTUALNR)) AS Result UNION
SELECT 'FatherhoodIncomingErrandMissingChildSurname' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0E50 WHERE LD0V0E50.BARNEFTERNAMN = ' ') AS Result UNION
SELECT 'FatherhoodInformationFatherHasNotInvalidIdentityType' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0E55 E55 WHERE E55.FADFOREPNR != '' AND (E55.FADFORFODDAT != '' OR E55.FADFORSAMORDNINGSNR != '')) AS Result UNION
SELECT 'FatherhoodInformationHasConnectionToMissingDecision' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0E55 E55 WHERE E55.BESLUTNR > 0 AND NOT EXISTS(SELECT 'X' FROM LD0VYE E WHERE E55.BESLUTNR = E.BESLUTNR)) AS Result UNION
SELECT 'FatherhoodInformationHasCorrectType' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0E55 E55 WHERE E55.HANDLINGSTYP NOT IN(1,2,3,4,5,6,7,8,9)) AS Result UNION
SELECT 'FatherhoodInformationMissingIncomingErrand' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0E55 E55 WHERE E55.HANDLINGSTYP IN (1,2) AND NOT EXISTS(SELECT 'X' FROM LD0V0E50 E50 WHERE E55.FSUNDERATTELSENR = E50.FSUNDERATTELSENR)) AS Result UNION
SELECT 'FatherhoodInformationPartnerHasNotInvalidIdentityType' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0E55 E55 WHERE E55.MAKEPNR != '' AND (E55.MAKEFODDAT != '' OR E55.MAKESAMORDNINGSNR != '')) AS Result UNION
SELECT 'FatherhoodInformationTypeCorrectionHasIncomingErrand' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0E55 E55 WHERE E55.HANDLINGSTYP = 3  AND EXISTS(SELECT 'X' FROM LD0V0E50 E50 WHERE E55.FSUNDERATTELSENR = E50.FSUNDERATTELSENR)) AS Result UNION
SELECT 'FatherhoodSentInformationHasvalidConnectionToFatherhoodInformation' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0E56 E56 WHERE NOT EXISTS(SELECT 'X' FROM LD0V0E55 E55 WHERE E56.FSUPPGIFTNR = E55.FSUPPGIFTNR)) AS Result UNION
SELECT 'FeeMissingPeriod' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0N50 WHERE LD0V0N50.FOMDAT = ' ' OR LD0V0N50.TOMDAT = ' ') AS Result UNION
SELECT 'FeeMissingResourceAllocation' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0N50 WHERE LD0V0N50.RESTILLDNR > 0 AND NOT EXISTS (SELECT 'X' FROM LD0VYN70 WHERE LD0VYN70.RESTILLDNR = LD0V0N50.RESTILLDNR)) AS Result UNION
SELECT 'FeeSpecialMissingResourceAllocation' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0N51 WHERE LD0V0N51.RESTILLDNR > 0 AND NOT EXISTS (SELECT 'X' FROM LD0VYN70 WHERE LD0VYN70.RESTILLDNR = LD0V0N51.RESTILLDNR)) AS Result UNION
SELECT 'FormsMissingTypeCode' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0V04 WHERE TYPDOK > 0 AND NOT EXISTS (SELECT 'X' FROM LD0V0Q01 WHERE LD0V0Q01.KODTYP = 'TYPDOK' AND LD0V0Q01.KOD = LD0V0V04.TYPDOK)) AS Result UNION
SELECT 'GeneratedPdfGotResourceAllocationIdAndIsNotConnectedToJournalDigitalDocumentRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYPDF WHERE LD0VYPDF.TYPPDF <> 99 AND LD0VYPDF.RESTILLDNR > 0 AND NOT EXISTS (SELECT 'X' FROM LD0V0R51 WHERE LD0V0R51.DOKUMENTID = LD0VYPDF.DOKUMENTID) AND LD0VYPDF.DATUM > '20190101') AS Result UNION
SELECT 'GeneratedPdfMissingDateOrUseridOrTime' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYPDF WHERE LD0VYPDF.DATUM = ' ' OR LD0VYPDF.SIGNATUR = ' ' OR LD0VYPDF.KLOCKSLAG = ' ') AS Result UNION
SELECT 'GeneratedPdfMissingInAssignmentIFORegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYPDF WHERE LD0VYPDF.UPPDRAGIFONR > 0 AND NOT EXISTS (SELECT 'X' FROM LD0VYN900 WHERE LD0VYPDF.UPPDRAGIFONR = LD0VYN900.UPPDRAGIFONR)) AS Result UNION
SELECT 'GeneratedPdfMissingInAssignmentOtherRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYPDF WHERE LD0VYPDF.LNUPPDRAGNR > 0 AND NOT EXISTS (SELECT 'X' FROM LD0VYU90 WHERE LD0VYU90.LNUPPDRAGNR = LD0VYPDF.LNUPPDRAGNR)) AS Result UNION
SELECT 'GeneratedPdfMissingInAssignmentRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYPDF WHERE LD0VYPDF.UPPDRAGNR > 0 AND NOT EXISTS (SELECT 'X' FROM LD0VYN90 WHERE LD0VYN90.UPPDRAGNR = LD0VYPDF.UPPDRAGNR)) AS Result UNION
SELECT 'GeneratedPdfMissingOwnerData' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYPDF WHERE LD0VYPDF.OBJEKT = ' ' OR LD0VYPDF.OBJEKTNYCKEL = ' ' AND DATUM > '20170101') AS Result UNION
SELECT 'GeneratedPdfMissingOwnerInDocumentPdfRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYPDF WHERE LD0VYPDF.OBJEKT = 'IFO.InfogatDokument' AND NOT EXISTS (SELECT 'X' FROM LD0V0T43 WHERE LD0V0T43.INFOGANR = LD0VYPDF.OBJEKTNYCKEL) AND LD0VYPDF.DATUM > '20170101') AS Result UNION
SELECT 'GeneratedPdfMissingOwnerInDocumentRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYPDF WHERE LD0VYPDF.OBJEKT = 'IFO.Dokument' AND NOT EXISTS (SELECT 'X' FROM LD0V0T41 WHERE LD0V0T41.DOKUMENTNR = LD0VYPDF.OBJEKTNYCKEL) AND LD0VYPDF.DATUM > '20170101') AS Result UNION
SELECT 'GeneratedPdfMissingOwnerInJournalDigitalRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYPDF WHERE LD0VYPDF.OBJEKT = 'IFO.JournalDigital' AND NOT EXISTS (SELECT 'X' FROM LD0V0R50 WHERE LD0V0R50.JDINTLNR = LD0VYPDF.OBJEKTNYCKEL) AND LD0VYPDF.DATUM > '20120101') AS Result UNION
SELECT 'GeneratedPdfMissingOwnerInServiceRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYPDF WHERE LD0VYPDF.OBJEKT = 'IFO.Insats' AND NOT EXISTS (SELECT 'X' FROM LD0VYC20 WHERE LD0VYC20.INSNR = LD0VYPDF.OBJEKTNYCKEL) AND LD0VYPDF.DATUM > '20160101') AS Result UNION
SELECT 'GoalCompletionMissingInTargetRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0M12 WHERE NOT EXISTS (SELECT 'X' FROM LD0V0M11 WHERE LD0V0M11.MALNR = LD0V0M12.MALNR AND LD0V0M11.MALSATTN = LD0V0M12.MALSATTN)) AS Result UNION
SELECT 'GoalReviewMissingInGoalCompletionRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0M13 WHERE NOT EXISTS (SELECT 'X' FROM LD0V0M12 WHERE LD0V0M12.MALNR = LD0V0M13.MALNR AND LD0V0M12.MALSATTN = LD0V0M13.MALSATTN AND LD0V0M12.MALUPFNR = LD0V0M13.MALUPFNR)) AS Result UNION
SELECT 'HiddenGuardianMissingInPersonRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0Y15 WHERE NOT EXISTS (SELECT 'X' FROM LD0V0A WHERE LD0V0A.PNR = LD0V0Y15.PNR)) AS Result UNION
SELECT 'HouseholdMissingHouseholdLeader' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0K WHERE NOT EXISTS (SELECT 'X' FROM LD0V0K01 WHERE LD0V0K01.HUSHLNR = LD0V0K.HUSHLNR AND LD0V0K01.FAMHUVUD = 1)) AS Result UNION
SELECT 'HouseholdMissingHouseholdPersons' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0K WHERE NOT EXISTS (SELECT 'X' FROM LD0V0K01 WHERE LD0V0K01.HUSHLNR = LD0V0K.HUSHLNR)) AS Result UNION
SELECT 'HouseholdPersonsMissingHousehold' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0K01 WHERE NOT EXISTS (SELECT 'X' FROM LD0V0K WHERE LD0V0K.HUSHLNR = LD0V0K01.HUSHLNR)) AS Result UNION
SELECT 'HouseholdPersonsMissingInPersonRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0K01 WHERE NOT EXISTS (SELECT 'X' FROM LD0V0A WHERE LD0V0A.PNR = LD0V0K01.PNR)) AS Result UNION
SELECT 'HouseholdPersonsMissingMarkingInPersonRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0A WHERE LD0V0A.HARHUSHALL = 0 AND EXISTS (SELECT 'X' FROM LD0V0K01 WHERE LD0V0K01.PNR = LD0V0A.PNR)) AS Result UNION
SELECT 'HouseholdPersonsWithWrongPersonId' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0K01 WHERE LD0V0K01.PNR = ' ' OR LD0V0K01.PNR LIKE '%*%') AS Result UNION
SELECT 'HouseholdWrongPeriod' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0K WHERE LD0V0K.FOMDAT = ' ' OR LD0V0K.TOMDAT = ' ') AS Result UNION
SELECT 'InpaymentListTextWherePaymentIsMissing' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0F40 WHERE LD0V0F40.BETALNR > 0 AND NOT EXISTS (SELECT 'X' FROM LD0VYF WHERE LD0VYF.BETALNR = LD0V0F40.BETALNR)) AS Result UNION
SELECT 'InpaymentMissingJournalEvent' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYF WHERE BETSATT = 90 AND NOT STATUS = 9 AND NOT EXISTS (SELECT 'X' FROM LD0VYC11 WHERE HTYP = 150 AND LD0VYC11.HAGNR = LD0VYF.BETALNR) AND BETALNR > 3981) AS Result UNION
SELECT 'InpaymentToDecisionWhereDecisionIsMissing' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0F04 WHERE NOT EXISTS (SELECT 'X' FROM LD0VYE WHERE LD0VYE.BESLUTNR = LD0V0F04.BESLUTNR)) AS Result UNION
SELECT 'InpaymentToDecisionWhereInpaymentIsMissing' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0F04 WHERE NOT EXISTS (SELECT 'X' FROM LD0VYF WHERE LD0VYF.BETALNR = LD0V0F04.BETALNR)) AS Result UNION
SELECT 'InstrumentXPersonMissingInPersonRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0A40 WHERE NOT PERSONNR IN(SELECT PNR FROM LD0VAA0PER)) AS Result UNION
SELECT 'InternshipBudgetHasConnectionToInternship' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0U63 WHERE LD0V0U63.PRAKPROJNR >= 0 AND NOT EXISTS(SELECT 'X' FROM LD0V0U60 WHERE LD0V0U60.PRAKPROJNR = LD0V0U63.PRAKPROJNR)) AS Result UNION
SELECT 'InternshipContactHasConnectionToInternship' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0U62 WHERE LD0V0U62.PRAKPROJNR >= 0 AND NOT EXISTS(SELECT 'X' FROM LD0V0U60 WHERE LD0V0U60.PRAKPROJNR = LD0V0U62.PRAKPROJNR)) AS Result UNION
SELECT 'InternshipHasConnectionToInternshipOrganizer' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0U60 WHERE LD0V0U60.ANORDNARNR > 0 AND NOT EXISTS(SELECT 'X' FROM LD0VYU50 WHERE LD0VYU50.ANORDNARE = 1 AND LD0VYU50.ANORDUTFORNR = LD0V0U60.ANORDNARNR)) AS Result UNION
SELECT 'InternshipHasCorrectDates' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0U60 WHERE LD0V0U60.FROMDAT = '' OR LD0V0U60.FROMDAT = '00000000' OR LD0V0U60.FROMDAT = '99999999' OR LD0V0U60.TOMDAT = '' OR LD0V0U60.TOMDAT = '00000000' OR LD0V0U60.TOMDAT = '99999999') AS Result UNION
SELECT 'InternshipOrganizerUserHasConnectionToInternshipOrganizer' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0U51 WHERE LD0V0U51.ANORDUTFORNR >= 0 AND NOT EXISTS(SELECT 'X' FROM LD0VYU50 WHERE LD0VYU50.ANORDUTFORNR = LD0V0U51.ANORDUTFORNR)) AS Result UNION
SELECT 'InternshipPositionHasConnectionToInternship' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0U64 WHERE LD0V0U64.PRAKPROJNR >= 0 AND NOT EXISTS(SELECT 'X' FROM LD0V0U60 WHERE LD0V0U60.PRAKPROJNR = LD0V0U64.PRAKPROJNR)) AS Result UNION
SELECT 'InternshipRequirementHasConnectionToInternship' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0U61 WHERE LD0V0U61.PRAKPROJNR > 0 AND NOT EXISTS(SELECT 'X' FROM LD0V0U60 WHERE LD0V0U60.PRAKPROJNR = LD0V0U61.PRAKPROJNR)) AS Result UNION
SELECT 'InternshipRequirementHasConnectionToSimplePlace' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0U61 WHERE LD0V0U61.ENKELPLATSNR > 0 AND NOT EXISTS(SELECT 'X' FROM LD0V0U70 WHERE LD0V0U70.ENKELPLATSNR = LD0V0U61.ENKELPLATSNR)) AS Result UNION
SELECT 'InvestigationCaseworkerHistoryMissingInCaseworkerRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0C02 WHERE NOT EXISTS (SELECT 'X' FROM LD0V0I WHERE LD0V0I.HAND = LD0V0C02.HAND)) AS Result UNION
SELECT 'InvestigationCaseworkerHistoryMissingInOrganisationRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0C02 WHERE LD0V0C02.ORGENHNR > ' ' AND NOT EXISTS (SELECT 'X' FROM LD0V0J01 WHERE LD0V0J01.ORGID = LD0V0C02.ORGID AND LD0V0J01.ORGENHNR = LD0V0C02.ORGENHNR)) AS Result UNION
SELECT 'InvestigationCaseworkerHistoryMissingInvestigation' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0C02 WHERE NOT LD0V0C02.AEVERKNR IN (SELECT LD0VYC.AEVERKNR FROM LD0VYC)) AS Result UNION
SELECT 'InvestigationCaseworkerHistoryWrongDates' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0C02 WHERE LD0V0C02.FOMDAT = ' ' OR LD0V0C02.TOMDAT = ' ') AS Result UNION
SELECT 'InvestigationCaseworkerMissingInCaseworkerRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYC WHERE NOT EXISTS (SELECT 'X' FROM LD0V0I WHERE LD0V0I.HAND = LD0VYC.HAND)) AS Result UNION
SELECT 'InvestigationCoCaseworkerHistoryMissingInCaseworkerRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0C02 WHERE LD0V0C02.MEDHAND > ' ' AND NOT EXISTS (SELECT 'X' FROM LD0V0I WHERE LD0V0I.HAND = LD0V0C02.MEDHAND)) AS Result UNION
SELECT 'InvestigationCoCaseworkerHistoryMissingInOrganisationRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0C02 WHERE LD0V0C02.ORGENHNR2 > ' ' AND NOT EXISTS (SELECT 'X' FROM LD0V0J01 WHERE LD0V0J01.ORGID = LD0V0C02.ORGID AND LD0V0J01.ORGENHNR = LD0V0C02.ORGENHNR2)) AS Result UNION
SELECT 'InvestigationCoCaseworkerMissingInCaseworkerRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYC WHERE LD0VYC.MEDHAND > ' ' AND NOT EXISTS (SELECT 'X' FROM LD0V0I WHERE LD0V0I.HAND = LD0VYC.MEDHAND)) AS Result UNION
SELECT 'InvestigationOrganisationMissingInRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYC WHERE LD0VYC.ORGENHNR > ' ' AND NOT EXISTS (SELECT 'X' FROM LD0V0J01 WHERE LD0V0J01.ORGID = LD0VYC.ORGID AND LD0V0J01.ORGENHNR = LD0VYC.ORGENHNR)) AS Result UNION
SELECT 'InvestigationPartsMissingInPersonRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0C03 WHERE NOT LD0V0C03.REFPNR IN (SELECT LD0V0A.PNR FROM LD0V0A)) AS Result UNION
SELECT 'InvestigationPartsWithoutInvestigation' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0C03 WHERE NOT LD0V0C03.AEVERKNR IN (SELECT LD0VYC.AEVERKNR FROM LD0VYC WHERE LD0VYC.TMARK = 0)) AS Result UNION
SELECT 'InvestigationPersonsWithoutInvestigation' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0C01 WHERE NOT LD0V0C01.AEVERKNR IN (SELECT LD0VYC.AEVERKNR FROM LD0VYC WHERE LD0VYC.TMARK = 0)) AS Result UNION
SELECT 'InvestigationsConnectedToWrongDossier' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT LD0VYC.* FROM LD0VYC, LD0VYB WHERE LD0VYC.AKTNR = LD0VYB.AKTNR AND NOT LD0VYC.AKTPNR = LD0VYB.AKTPNR) AS Result UNION
SELECT 'InvestigationsMissingDossier' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYC WHERE NOT LD0VYC.AKTNR IN(SELECT LD0VYB.AKTNR FROM LD0VYB)) AS Result UNION
SELECT 'InvestigationsMissingInvestigationPersons' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYC WHERE LD0VYC.TMARK = 0 AND NOT LD0VYC.AEVERKNR IN(SELECT LD0V0C01.AEVERKNR FROM LD0V0C01)) AS Result UNION
SELECT 'InvestigationsWithoutChain' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYC WHERE LD0VYC.TMARK = 0 AND NOT EXISTS (SELECT 'X' FROM LD0VYC10 WHERE LD0VYC10.ARENDENR = LD0VYC.AEVERKNR)) AS Result UNION
SELECT 'InvestigationsWithWrongPersonId' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYC WHERE AKTPNR LIKE '%*%' OR AKTPNR = ' ') AS Result UNION
SELECT 'InvestigationWrongStartDates' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYC WHERE NOT LD0VYC.STARTDAT LIKE '19%' AND NOT LD0VYC.STARTDAT LIKE '20%') AS Result UNION
SELECT 'InvestigationWrongStopDates' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYC WHERE NOT LD0VYC.STOPDAT LIKE '19%' AND NOT LD0VYC.STOPDAT LIKE '20%' AND NOT LD0VYC.STOPDAT LIKE '99%') AS Result UNION
SELECT 'JournalDigitalDocumentMissingInGeneratedPdfRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0R51 WHERE LD0V0R51.DOKUMENTID != ' ' AND NOT EXISTS (SELECT 'X' FROM LD0VYPDF WHERE LD0VYPDF.DOKUMENTID = LD0V0R51.DOKUMENTID)) AS Result UNION
SELECT 'JournalDigitalDocumentMissingJournalDigital' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0R51 WHERE NOT EXISTS (SELECT 'X' FROM LD0V0R50 WHERE LD0V0R50.JDINTLNR = LD0V0R51.INTEGRATIONNO)) AS Result UNION
SELECT 'JournalDigitalMissingJdVdHemId' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0R50 WHERE LD0V0R50.JDINTLNR > 350 AND LD0V0R50.JDVDHEMID = ' ' ) AS Result UNION
SELECT 'JournalDigitalMissingJdVdHemIdInCodeTextRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0R50 WHERE LD0V0R50.JDINTLNR > 350 AND NOT EXISTS (SELECT 'X' FROM LD0V0Q01 WHERE LD0V0Q01.KODTYP = 'JDBHEM' AND LD0V0Q01.EXTKOD = LD0V0R50.JDVDHEMID)) AS Result UNION
SELECT 'JournalDigitalMissingJournalEvent' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0R50 WHERE LD0V0R50.INSNR > 0 AND NOT EXISTS (SELECT 'X' FROM LD0VYC11 WHERE LD0VYC11.INSNR = LD0V0R50.INSNR AND LD0VYC11.HAGNR = LD0V0R50.JDINTLNR AND LD0VYC11.HTYP = 380)) AS Result UNION
SELECT 'JournalDigitalMissingMottagareId' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0L WHERE LD0V0L.MOTTAGAREID != ' ' AND NOT EXISTS (SELECT 'X' FROM LD0V0Q01 WHERE LD0V0Q01.KODTYP = 'JDBHEM' AND LD0V0Q01.EXTKOD = LD0V0L.MOTTAGAREID)) AS Result UNION
SELECT 'JournalDigitalMissingResourceAllocation' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0R50 WHERE LD0V0R50.RESTILLDNR > 0 AND NOT EXISTS (SELECT 'X' FROM LD0VYN70 WHERE LD0VYN70.RESTILLDNR = LD0V0R50.RESTILLDNR)) AS Result UNION
SELECT 'JournalDigitalMissingResourceAllocationId' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0R50 WHERE LD0V0R50.JDINTLNR > 350 AND LD0V0R50.RESTILLDNR = 0 ) AS Result UNION
SELECT 'JournalDigitalMissingService' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0R50 WHERE LD0V0R50.INSNR > 0 AND NOT EXISTS (SELECT 'X' FROM LD0VYC20 WHERE LD0VYC20.INSNR = LD0V0R50.INSNR)) AS Result UNION
SELECT 'JournalDigitalMissingServiceId' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0R50 WHERE LD0V0R50.JDINTLNR > 350 AND LD0V0R50.INSNR = 0 ) AS Result UNION
SELECT 'JournalEventAdjustMoneyMissingOwner' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYC11 WHERE LD0VYC11.HTYP = 141 AND NOT EXISTS (SELECT 'X' FROM LD0VYF WHERE LD0VYF.BETALNR = LD0VYC11.HAGNR)) AS Result UNION
SELECT 'JournalEventBalanceAdjustmentMissingOwner' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYC11 WHERE LD0VYC11.HTYP = 140 AND NOT EXISTS (SELECT 'X' FROM LD0VYF WHERE LD0VYF.BETALNR = LD0VYC11.HAGNR)) AS Result UNION
SELECT 'JournalEventCalculationMissingOwner' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYC11 WHERE LD0VYC11.HTYP = 110 AND NOT EXISTS (SELECT 'X' FROM LD0VYD WHERE LD0VYD.BERAKNR = LD0VYC11.HAGNR)) AS Result UNION
SELECT 'JournalEventDecisionMissingOwner' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYC11 WHERE (LD0VYC11.HTYP = 120 OR LD0VYC11.HTYP = 125) AND NOT EXISTS (SELECT 'X' FROM LD0VYE WHERE LD0VYE.BESLUTNR = LD0VYC11.HAGNR)) AS Result UNION
SELECT 'JournalEventEmptyUpdateSignature' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYC11 WHERE LD0VYC11.UPDSIGN = ' ' ) AS Result UNION
SELECT 'JournalEventExecutionMissingOwner' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYC11 WHERE (LD0VYC11.HTYP = 10 OR LD0VYC11.HTYP = 430) AND NOT EXISTS (SELECT 'X' FROM LD0VYC WHERE LD0VYC.AEVERKNR = LD0VYC11.HAGNR)) AS Result UNION
SELECT 'JournalEventInpaymentMissingOwner' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYC11 WHERE LD0VYC11.HTYP = 150 AND NOT EXISTS (SELECT 'X' FROM LD0VYF WHERE LD0VYF.BETALNR = LD0VYC11.HAGNR) AND NOT LD0VYC11.AEVERKNR IN (3044,3143,4612,4653,4658)) AS Result UNION
SELECT 'JournalEventJournalDigitalMissingOwner' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYC11 WHERE LD0VYC11.HTYP = 380 AND NOT EXISTS (SELECT 'X' FROM LD0V0R50 WHERE LD0V0R50.JDINTLNR = LD0VYC11.HAGNR) ) AS Result UNION
SELECT 'JournalEventJournalNotificationMissingOwner' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYC11 WHERE LD0VYC11.HTYP = 80 AND NOT EXISTS (SELECT 'X' FROM LD0V0T50 WHERE LD0V0T50.ANTECKNR = LD0VYC11.HAGNR)) AS Result UNION
SELECT 'JournalEventMissingCommunication' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYC11 WHERE LD0VYC11.HTYP = 101 AND NOT EXISTS (SELECT 'X' FROM LD0V0H50 WHERE LD0V0H50.ID = LD0VYC11.HAGNR)) AS Result UNION
SELECT 'JournalEventMissingJournalDigital' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYC11 WHERE LD0VYC11.HTYP = 380 AND NOT EXISTS (SELECT 'X' FROM LD0V0R50 WHERE LD0V0R50.JDINTLNR = LD0VYC11.HAGNR)) AS Result UNION
SELECT 'JournalEventMissingOwnerId' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYC11 WHERE LD0VYC11.HAGNR = 0) AS Result UNION
SELECT 'JournalEventMissingText' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYC11 WHERE LD0VYC11.HTEXT1 = ' ') AS Result UNION
SELECT 'JournalEventOwnerMissingInServiceRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYC11 WHERE LD0VYC11.INSNR > 0 AND NOT EXISTS (SELECT 'X' FROM LD0VYC20 WHERE LD0VYC20.INSNR = LD0VYC11.INSNR)) AS Result UNION
SELECT 'JournalEventOwnFeeMissingOwner' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYC11 WHERE HTYP = 351 AND NOT EXISTS (SELECT 'X' FROM LD0V0D50 WHERE LD0V0D50.EGBERAKNR = LD0VYC11.HAGNR) ) AS Result UNION
SELECT 'JournalEventPaymentMissingOwner' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYC11 WHERE LD0VYC11.HTYP = 160 AND NOT EXISTS (SELECT 'X' FROM LD0VYF WHERE LD0VYF.BETALNR = LD0VYC11.HAGNR) AND NOT LD0VYC11.AEVERKNR IN (3143,3542,4653)) AS Result UNION
SELECT 'JournalEventRequsitionMissingOwner' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYC11 WHERE LD0VYC11.HTYP = 170 AND NOT EXISTS (SELECT 'X' FROM LD0VYG WHERE LD0VYG.REKVNR = LD0VYC11.HAGNR) AND LD0VYC11.HAGNR > 537) AS Result UNION
SELECT 'JournalEventResourceAllocationInvoiceMissingOwner' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYC11 WHERE LD0VYC11.HTYP = 185 AND NOT EXISTS (SELECT 'X' FROM LD0V0N30 WHERE LD0V0N30.FAKTURANR = LD0VYC11.HAGNR) ) AS Result UNION
SELECT 'JournalEventResourceAllocationMissingOwner' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYC11 WHERE LD0VYC11.HTYP = 195 AND NOT EXISTS (SELECT 'X' FROM LD0VYN70 WHERE LD0VYN70.RESTILLDNR = LD0VYC11.HAGNR) ) AS Result UNION
SELECT 'JournalEventsAktualiseringMissingOwner' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYC11 WHERE LD0VYC11.HTYP = 30 AND NOT EXISTS (SELECT 'X' FROM LD0VYH WHERE LD0VYH.AKTUALNR = LD0VYC11.HAGNR)) AS Result UNION
SELECT 'JournalEventServiceMissingOwner' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYC11 WHERE (LD0VYC11.HTYP = 130 OR LD0VYC11.HTYP = 400) AND NOT EXISTS (SELECT 'X' FROM LD0VYC20 WHERE LD0VYC20.INSNR = LD0VYC11.HAGNR)) AS Result UNION
SELECT 'JournalEventsInvestigationMissingOwner' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYC11 WHERE (LD0VYC11.HTYP = 40 OR LD0VYC11.HTYP = 420) AND NOT EXISTS (SELECT 'X' FROM LD0VYC WHERE LD0VYC.AEVERKNR = LD0VYC11.HAGNR)) AS Result UNION
SELECT 'JournalEventsWithIncorrectUpdateTimestamp' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYC11 WHERE LEN(UPDDAT) < 6) AS Result UNION
SELECT 'JournalEventWithoutInvestigationExecutionId' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYC11 WHERE LD0VYC11.AEVERKNR = 0) AS Result UNION
SELECT 'JournalEventWrongDates' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYC11 WHERE NOT LD0VYC11.HDATUM LIKE '19%' AND NOT LD0VYC11.HDATUM LIKE '20%') AS Result UNION
SELECT 'JournalEventWrongTimeDate' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYC11 WHERE (LD0VYC11.TID = ' ' OR LD0VYC11.UPDDAT = ' ') AND NOT LD0VYC11.AEVERKNR = 5419) AS Result UNION
SELECT 'JournalNotificationMissingInvestigationOwner' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0T50 WHERE LD0V0T50.AEVERKNR > 0 AND NOT EXISTS (SELECT 'X' FROM LD0VYC WHERE LD0VYC.AEVERKNR = LD0V0T50.AEVERKNR) ) AS Result UNION
SELECT 'JournalNotificationMissingServiceOwner' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0T50 WHERE LD0V0T50.INSNR > 0 AND NOT EXISTS (SELECT 'X' FROM LD0VYC20 WHERE LD0VYC20.INSNR = LD0V0T50.INSNR) ) AS Result UNION
SELECT 'KeyCodeAreasMissingInAreacodesRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0J21 WHERE NOT EXISTS (SELECT 'X' FROM LD0V0J11 WHERE LD0V0J11.OMRENHNR = LD0V0J21.OMRENHNR)) AS Result UNION
SELECT 'KeyCodesMissingInAreaRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0J20 WHERE NOT EXISTS (SELECT 'X' FROM LD0V0J10 WHERE LD0V0J10.OMRID = LD0V0J20.OMRID)) AS Result UNION
SELECT 'KlientPersonWhoAreNotDossierPerson' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VAA0PER WHERE AKTRAKN = 0 and KLIENTRAKN > 0) AS Result UNION
SELECT 'LifeAreasMissingCodesInCodeTextRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0V18 WHERE NOT EXISTS (SELECT 'X' FROM LD0V0Q01 WHERE LD0V0Q01.KODTYP = 'AVSNITTTYP' AND LD0V0Q01.KOD = LD0V0V18.AVSNITTSTYP)) AS Result UNION
SELECT 'LifeAreasMissingPersonInPersonRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0V18 WHERE NOT EXISTS (SELECT 'X' FROM LD0V0A WHERE LD0V0A.PNR = LD0V0V18.PNR)) AS Result UNION
SELECT 'LMAssignmentHasCorrectDates' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYU90 WHERE LD0VYU90.BESTDAT = '' OR LD0VYU90.BESTDAT = '00000000' OR LD0VYU90.BESTDAT = '99999999' OR LD0VYU90.FOMDAT = '00000000' OR LD0VYU90.FOMDAT = '99999999' OR LD0VYU90.TOMDAT = '00000000' OR LD0VYU90.TOMDAT = '99999999' OR LD0VYU90.MOTDAT = '00000000' OR LD0VYU90.MOTDAT = '99999999' OR LD0VYU90.ATERTAGDAT = '00000000' OR LD0VYU90.ATERTAGDAT = '99999999' OR LD0VYU90.AVBOJDAT = '00000000' OR LD0VYU90.AVBOJDAT = '99999999') AS Result UNION
SELECT 'LMAssignmentMissingDecision' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYU90 WHERE LD0VYU90.BESLUTNR = 0) AS Result UNION
SELECT 'LMAssignmentMissingDecisionInRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYU90 WHERE LD0VYU90.BESLUTNR > 0 AND UTANIFO = 0 AND NOT EXISTS (SELECT 'X' FROM LD0VYE WHERE LD0VYE.BESLUTNR = LD0VYU90.BESLUTNR)) AS Result UNION
SELECT 'LMAssignmentMissingDirective' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYU90 WHERE LD0VYU90.ANVISANDENR > 0 AND NOT EXISTS (SELECT 'X' FROM LD0V0U11 WHERE LD0VYU90.ANVISANDENR = LD0V0U11.ANVISANDENR)) AS Result UNION
SELECT 'LMAssignmentMissingEnrollment' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYU90 WHERE LD0VYU90.INSKRIVNINGNR > 0 AND NOT EXISTS (SELECT 'X' FROM LD0VYU10 WHERE LD0VYU90.INSKRIVNINGNR = LD0VYU10.INSKRIVNINGSNR)) AS Result UNION
SELECT 'LMAssignmentWrongReceiverOrganization' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYU90 WHERE UTANIFO = 0 AND (LD0VYU90.MOTORGID = 0 OR MOTORGENHNR = '')) AS Result UNION
SELECT 'LMAssignmentWrongSenderOrganization' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYU90 WHERE UTANIFO = 0 AND (LD0VYU90.BESTORGID = 0 OR BESTORGENHNR = '')) AS Result UNION
SELECT 'LMDateScheduleActivityHasConnectionToEnrollmentPlanActivity' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VAA0LMDateSchedule WHERE LD0VAA0LMDateSchedule.PLANAKTIVITETNR > 0 AND NOT EXISTS(SELECT 'X' FROM LD0VYU34 WHERE LD0VAA0LMDateSchedule.PLANAKTIVITETNR = LD0VYU34.PLANAKTIVITETNR)) AS Result UNION
SELECT 'LMDateScheduleInternshipHasConnectionToInternship' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VAA0LMDateSchedule WHERE LD0VAA0LMDateSchedule.PRAKPROJNR > 0 AND NOT EXISTS(SELECT 'X' FROM LD0V0U60 WHERE LD0VAA0LMDateSchedule.PRAKPROJNR = LD0V0U60.PRAKPROJNR)) AS Result UNION
SELECT 'LMDateScheduleSimplePlaceHasConnectionToSimplePlace' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VAA0LMDateSchedule WHERE LD0VAA0LMDateSchedule.ENKELPLATSNR > 0 AND NOT EXISTS(SELECT 'X' FROM LD0V0U70 WHERE LD0VAA0LMDateSchedule.ENKELPLATSNR = LD0V0U70.ENKELPLATSNR)) AS Result UNION
SELECT 'LMDocumentTypeWithPlanSpecificMarkIsEnabledForPlans' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0Q01 WHERE LD0V0Q01.KODTYP = 'LNDOKTYP' AND LD0V0Q01.XNUM1 = 0 and LD0V0Q01.XNUM14 = 1) AS Result UNION
SELECT 'LMTypeHasOneComponentSelected' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0Q01 WHERE LD0V0Q01.KODTYP = 'LNDOKTYP' AND LD0V0Q01.XNUM1 + LD0V0Q01.XNUM2 + LD0V0Q01.XNUM3 + LD0V0Q01.XNUM4 + LD0V0Q01.XNUM5 + LD0V0Q01.XNUM6 + LD0V0Q01.XNUM7 + LD0V0Q01.XNUM8 + LD0V0Q01.XNUM9 + LD0V0Q01.XNUM10 + LD0V0Q01.XNUM11 != 1) AS Result UNION
SELECT 'MeetingInterpreterOrderHasConnectionToMeetingRegistration' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0U06 U06 WHERE U06.ANMALANSNR >= 0 AND NOT EXISTS(SELECT 'X' FROM LD0VYU05 U05 WHERE U05.ANMALANSNR = U06.ANMALANSNR)) AS Result UNION
SELECT 'MeetingOccationHasConnectionToMeeting' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYU76 U76 WHERE U76.MOTESNR >= 0 AND NOT EXISTS(SELECT 'X' FROM LD0VYU75 U75 WHERE U75.MOTESNR = U76.MOTESNR)) AS Result UNION
SELECT 'MeetingRegistrationHasConnectionToMeetingOccation' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYU05 U05 WHERE U05.MOTESTILLFNR >= 0 AND NOT EXISTS(SELECT 'X' FROM LD0VYU76 U76 WHERE U76.MOTESTILLFNR = U05.MOTESTILLFNR)) AS Result UNION
SELECT 'MissingNameForReferenceWithoutPersonId ' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0Y02 WHERE NAMN = ' ') AS Result UNION
SELECT 'MissionMissingResourceAllocation' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0N92 WHERE LD0V0N92.RESTILLDNR > 0 AND NOT EXISTS (SELECT 'X' FROM LD0VYN70 WHERE LD0VYN70.RESTILLDNR = LD0V0N92.RESTILLDNR)) AS Result UNION
SELECT 'MoreThanOneSurveyPostPerPeson' as TESTCASE   
,CASE WHEN COUNT(Result.PERSONNR) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT LD0V0U01.PERSONNR, COUNT(*) as ResultCount FROM LD0V0U01 GROUP BY LD0V0U01.PERSONNR HAVING COUNT(*) > 1) AS Result UNION
SELECT 'NormRowsMissingNorm' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0D11 WHERE NOT LD0V0D11.NORMNR IN(SELECT LD0V0D10.NORMNR FROM LD0V0D10)) AS Result UNION
SELECT 'NormSharedMissingNorm' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0D12 WHERE NOT LD0V0D12.NORMNR IN(SELECT LD0V0D10.NORMNR FROM LD0V0D10)) AS Result UNION
SELECT 'NormWrongPeriod' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0D10 WHERE FOMDAT = ' ' OR TOMDAT = ' ') AS Result UNION
SELECT 'OldNoteForNormMissingNormRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0T WHERE TAGTYP = 4 AND NOT EXISTS (SELECT 'X' FROM LD0V0D10 WHERE LD0V0D10.NORMNR = LD0V0T.ID)) AS Result UNION
SELECT 'OldReminderForNormMissingNormRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYP WHERE TAGTYP = 4 AND NOT EXISTS (SELECT 'X' FROM LD0V0D10 WHERE LD0V0D10.NORMNR = LD0VYP.ID)) AS Result UNION
SELECT 'OrdforandeMissingPersonId' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0Chairperson WHERE PERSONNR = '' ) AS Result UNION
SELECT 'OrganisationAddressMissingInAddressRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0J03 WHERE NOT EXISTS (SELECT 'X' FROM LD0V0I02 WHERE LD0V0I02.ADRKOD = LD0V0J03.ADRKOD)) AS Result UNION
SELECT 'OrganisationAddressMissingInOrganisationRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0J03 WHERE NOT EXISTS (SELECT 'X' FROM LD0V0J01 WHERE LD0V0J01.ORGID = LD0V0J03.ORGID AND LD0V0J01.ORGENHNR = LD0V0J03.ORGENHNR)) AS Result UNION
SELECT 'OrganisationNodeMissingInOrganisationRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0J01 WHERE NOT EXISTS (SELECT 'X' FROM LD0V0J WHERE LD0V0J.ORGID = LD0V0J01.ORGID)) AS Result UNION
SELECT 'OrganisationWrongPeriod' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0J WHERE LD0V0J.FOMDAT = ' ' OR LD0V0J.TOMDAT = ' ') AS Result UNION
SELECT 'OtherRelationHasMissingOtherRelationPerson' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0Y10 WHERE NOT EXISTS (SELECT 'X' FROM LD0V0Y11 WHERE LD0V0Y11.RELNR = LD0V0Y10.RELNR)) AS Result UNION
SELECT 'OtherRelationMissingInPersonRegister ' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0Y10 WHERE NOT EXISTS (SELECT 'X' FROM LD0V0A WHERE LD0V0A.PNR = LD0V0Y10.PNR)) AS Result UNION
SELECT 'OtherRelationSubDataHaveNoParent' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0Y11 WHERE NOT EXISTS(SELECT 'X' FROM LD0V0Y10 WHERE LD0V0Y10.RELNR = LD0V0Y11.RELNR) ) AS Result UNION
SELECT 'OwnContributionMissingPeriod' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0N20 WHERE LD0V0N20.FOMDAT = ' ' OR LD0V0N20.TOMDAT = ' ') AS Result UNION
SELECT 'OwnContributionMissingService' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0N20 WHERE NOT EXISTS (SELECT 'X' FROM LD0VYC20 WHERE LD0VYC20.INSNR = LD0V0N20.INSATSNR)) AS Result UNION
SELECT 'OwnFeeMissingResourceAllocationRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0D51 WHERE LD0V0D51.RESTILLDNR > 0 AND NOT EXISTS (SELECT 'X' FROM LD0VYN70 WHERE LD0VYN70.RESTILLDNR = LD0V0D51.RESTILLDNR)) AS Result UNION
SELECT 'OwnFeeWithNoJournalEvent' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0D50 WHERE NOT EXISTS (SELECT 'X' FROM LD0VYC11 WHERE HTYP = 351 AND LD0VYC11.HAGNR = LD0V0D50.EGBERAKNR)) AS Result UNION
SELECT 'OwnFeeWithNoPlacedChild' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0D50 WHERE NOT EXISTS (SELECT 'X' FROM LD0V0D51  WHERE LD0V0D51 .EGBERAKNR = LD0V0D50.EGBERAKNR)) AS Result UNION
SELECT 'PayeeMissingInPersonRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0F30 WHERE LD0V0F30.PNR > ' ' AND NOT LD0V0F30.PNR IN (SELECT LD0V0A.PNR FROM LD0V0A)) AS Result UNION
SELECT 'PaymentAdjustmentMissingJournalEvent' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYF WHERE BETTYP = 91 AND NOT EXISTS (SELECT 'X' FROM LD0VYC11 WHERE HTYP = 141 AND LD0VYC11.HAGNR = LD0VYF.BETALNR) AND BETALNR > 3282) AS Result UNION
SELECT 'PaymentMissingAktualisering' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYF WHERE LD0VYF.AKTUALNR > 0 AND NOT EXISTS (SELECT 'X' FROM LD0VYH WHERE LD0VYH.AKTUALNR = LD0VYF.AKTUALNR)) AS Result UNION
SELECT 'PaymentMissingBalance' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYF WHERE LD0VYF.INSNR > 0 AND LD0VYF.BETTYP < 90 AND NOT LD0VYF.BETSATT = 90 AND NOT EXISTS (SELECT 'X' FROM LD0V0C24 WHERE LD0V0C24.INSNR = LD0VYF.INSNR AND LD0V0C24.AGARTYP = LD0VYF.AGARTYP AND LD0V0C24.AGARNR = LD0VYF.AGARNR AND LD0V0C24.BETALTYP = LD0VYF.BETTYP) AND LD0VYF.AGARNR > 242) AS Result UNION
SELECT 'PaymentMissingJournalEvent' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYF WHERE NOT BETTYP = 90 AND NOT BETTYP = 91 AND NOT BETSATT = 90 AND NOT STATUS = 9 AND NOT EXISTS (SELECT 'X' FROM LD0VYC11 WHERE HTYP = 160 AND LD0VYC11.HAGNR = LD0VYF.BETALNR) AND BETALNR > 4304) AS Result UNION
SELECT 'PaymentMissingPaymentPersons' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYF WHERE LD0VYF.INSNR > 0 AND LD0VYF.BETTYP < 90 AND NOT EXISTS (SELECT 'X' FROM LD0V0F01 WHERE LD0V0F01.BETALNR = LD0VYF.BETALNR)) AS Result UNION
SELECT 'PaymentMissingService' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYF WHERE LD0VYF.INSNR > 0 AND NOT LD0VYF.INSNR IN(SELECT LD0VYC20.INSNR FROM LD0VYC20)) AS Result UNION
SELECT 'PaymentPersonsMissingInPersonRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0F01 WHERE NOT LD0V0F01.PNR IN (SELECT LD0V0A.PNR FROM LD0V0A)) AS Result UNION
SELECT 'PaymentPersonsMissingPayment' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0F01 WHERE NOT EXISTS (SELECT 'X' FROM LD0VYF WHERE LD0VYF.BETALNR = LD0V0F01.BETALNR)) AS Result UNION
SELECT 'PaymentPostingMissingPayment' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0F02 WHERE NOT LD0V0F02.BETALNR IN (SELECT LD0VYF.BETALNR FROM LD0VYF)) AS Result UNION
SELECT 'PaymentPostingMissingPosting' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0F02 WHERE NOT LD0V0F02.KONTO > ' ') AS Result UNION
SELECT 'PaymentTextWherePaymentIsMissing' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0F05 WHERE NOT EXISTS (SELECT 'X' FROM LD0VYF WHERE LD0VYF.BETALNR = LD0V0F05.BETALNR)) AS Result UNION
SELECT 'PaymentWrongDates' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYF WHERE NOT LD0VYF.BETDAT LIKE '19%' AND NOT LD0VYF.BETDAT LIKE '20%') AS Result UNION
SELECT 'PdfSignEventMissingDocumentId' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0PDFSignEvents WHERE DOKUMENTID = '' ) AS Result UNION
SELECT 'PersonBornCountryMissingInBornCountryRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0A WHERE LD0V0A.FODLAND > 0 AND LD0V0A.FODLAND < 9999 AND LD0V0A.FODLAND NOT IN(SELECT KOD FROM LD0V0Q01 WHERE LD0V0Q01.KODTYP = 'LAND')) AS Result UNION
SELECT 'PersonCitizenshipMissingInCitizenshipRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0A WHERE LD0V0A.MEDBSKAP > 0 AND LD0V0A.MEDBSKAP < 9999 AND LD0V0A.MEDBSKAP NOT IN(SELECT KOD FROM LD0V0Q01 WHERE LD0V0Q01.KODTYP = 'LAND')) AS Result UNION
SELECT 'PersonCountyMissingInCountyRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0A WHERE LD0V0A.FOLKLAN > 0 AND LD0V0A.FOLKLAN < 9999 AND LD0V0A.FOLKLAN NOT IN(SELECT KOD FROM LD0V0Q01 WHERE LD0V0Q01.KODTYP = 'LÄN')) AS Result UNION
SELECT 'PersonHistoryWithoutPersonId' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0A01 WHERE PNR = ' ') AS Result UNION
SELECT 'PersonId2InReferenceButHasNoPerson' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0Y WHERE NOT EXISTS(SELECT 'X' FROM LD0V0A WHERE LD0V0A.PNR = LD0V0Y.REFPNR)) AS Result UNION
SELECT 'PersonIdInReferenceButHasNoPerson' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0Y WHERE NOT EXISTS(SELECT 'X' FROM LD0V0A WHERE LD0V0A.PNR = LD0V0Y.PNR)) AS Result UNION
SELECT 'PersonLanguage1MissingInLanguageRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0A WHERE LD0V0A.KOMSPRAK > 0 AND LD0V0A.KOMSPRAK < 9999 AND LD0V0A.KOMSPRAK NOT IN(SELECT KOD FROM LD0V0Q01 WHERE LD0V0Q01.KODTYP = 'SPRAK')) AS Result UNION
SELECT 'PersonLanguage2MissingInLanguageRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0A WHERE LD0V0A.KOMSPRAK2 > 0 AND LD0V0A.KOMSPRAK2 < 9999 AND LD0V0A.KOMSPRAK2 NOT IN(SELECT KOD FROM LD0V0Q01 WHERE LD0V0Q01.KODTYP = 'SPRAK')) AS Result UNION
SELECT 'PersonLanguage3MissingInLanguageRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0A WHERE LD0V0A.KOMSPRAK3 > 0 AND LD0V0A.KOMSPRAK3 < 9999 AND LD0V0A.KOMSPRAK3 NOT IN(SELECT KOD FROM LD0V0Q01 WHERE LD0V0Q01.KODTYP = 'SPRAK')) AS Result UNION
SELECT 'PersonMaritalStatusMissingInMaritalStatusRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0A WHERE LD0V0A.CIVKOD > 0 AND LD0V0A.CIVKOD < 9999 AND LD0V0A.CIVKOD NOT IN(SELECT KOD FROM LD0V0Q01 WHERE LD0V0Q01.KODTYP = 'CIVS')) AS Result UNION
SELECT 'PersonMissingName' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VAA0PER WHERE NAMN = ' ') AS Result UNION
SELECT 'PersonMunicipalityMissingInMunicipalityRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0A WHERE LD0V0A.FOLKKOM > 0 AND LD0V0A.FOLKKOM < 9999 AND LD0V0A.FOLKKOM NOT IN(SELECT KOD FROM LD0V0Q01 WHERE LD0V0Q01.KODTYP = 'KOMU')) AS Result UNION
SELECT 'PersonNativeLanguageMissingInNativeLanguageRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0A WHERE LD0V0A.MODMAL > 0 AND LD0V0A.MODMAL < 9999 AND LD0V0A.MODMAL NOT IN(SELECT KOD FROM LD0V0Q01 WHERE LD0V0Q01.KODTYP = 'SPRAK')) AS Result UNION
SELECT 'PersonRefraknIsWrongComparedToReference' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT A.PNR,A.KUNDNUMMER, A.REFRAKN,(SELECT COUNT(Y.REFPNR) FROM LD0VYY Y WHERE Y.REFPNR = A.PNR) AS SUM_REF FROM LD0VYA A WHERE A.REFRAKN != (SELECT COUNT(Y.REFPNR) FROM LD0VYY Y WHERE Y.REFPNR = A.PNR )) AS Result UNION
SELECT 'PersonWithoutBirthDate' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0A WHERE FODDAT = ' ') AS Result UNION
SELECT 'PersonWithoutUpdateDateOrSignature' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0A WHERE UPDDAT = ' ' OR UPDSIGN = ' ') AS Result UNION
SELECT 'PlacedChildWithOwnFeeThatDoesNotExist' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0D51 WHERE NOT EXISTS (SELECT 'X' FROM LD0V0D50 WHERE LD0V0D50.EGBERAKNR = LD0V0D51.EGBERAKNR)) AS Result UNION
SELECT 'PlacedChildWithServiceThatDoesNotExist' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0D51 WHERE NOT EXISTS (SELECT 'X' FROM LD0VYC20 WHERE LD0VYC20.INSNR = LD0V0D51.INSATSNR)) AS Result UNION
SELECT 'PostingAccountWrongPeriod' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0F20 WHERE FOMDAT = ' ' OR TOMDAT = ' ') AS Result UNION
SELECT 'PricesMissingResourceAllocation' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0N71 WHERE LD0V0N71.RESTILLDNR > 0 AND NOT EXISTS (SELECT 'X' FROM LD0VYN70 WHERE LD0VYN70.RESTILLDNR = LD0V0N71.RESTILLDNR)) AS Result UNION
SELECT 'PrintingTemplateConnectionMissingInPrintingTemplateRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VAA0PRINTTEMPLATECONNECTION WHERE NOT EXISTS (SELECT 'X' FROM LD0VAA0PRINTTEMPLATE WHERE LD0VAA0PRINTTEMPLATE.ID = LD0VAA0PRINTTEMPLATECONNECTION.TEMPLATEID)) AS Result UNION
SELECT 'PrintingTemplateMissingContentInContentRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VAA0PRINTTEMPLATE WHERE NOT LD0VAA0PRINTTEMPLATE.CONTENTTEMPLATE = '00000000-0000-0000-0000-000000000000' AND NOT EXISTS (SELECT 'X' FROM LD0V0PrintPartialData WHERE LD0V0PrintPartialData.FILEID = LD0VAA0PRINTTEMPLATE.CONTENTTEMPLATE)) AS Result UNION
SELECT 'PrintingTemplateMissingContentInPartialContentRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VAA0PRINTTEMPLATE WHERE NOT LD0VAA0PRINTTEMPLATE.CONTENTTEMPLATE = '00000000-0000-0000-0000-000000000000' AND NOT EXISTS (SELECT 'X' FROM LD0V0PrintPartialMetaData WHERE LD0V0PrintPartialMetaData.FILEID = LD0VAA0PRINTTEMPLATE.CONTENTTEMPLATE)) AS Result UNION
SELECT 'PrintingTemplateMissingFooterInFooterRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VAA0PRINTTEMPLATE WHERE NOT LD0VAA0PRINTTEMPLATE.PAGEFOOTERTEMPLATE = '00000000-0000-0000-0000-000000000000' AND NOT EXISTS (SELECT 'X' FROM LD0V0PrintPartialData WHERE LD0V0PrintPartialData.FILEID = LD0VAA0PRINTTEMPLATE.PAGEFOOTERTEMPLATE)) AS Result UNION
SELECT 'PrintingTemplateMissingFooterInPartialFooterRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VAA0PRINTTEMPLATE WHERE NOT LD0VAA0PRINTTEMPLATE.PAGEFOOTERTEMPLATE = '00000000-0000-0000-0000-000000000000' AND NOT EXISTS (SELECT 'X' FROM LD0V0PrintPartialMetaData WHERE LD0V0PrintPartialMetaData.FILEID = LD0VAA0PRINTTEMPLATE.PAGEFOOTERTEMPLATE)) AS Result UNION
SELECT 'PrintingTemplateMissingHeaderInHeaderRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VAA0PRINTTEMPLATE WHERE NOT LD0VAA0PRINTTEMPLATE.PAGEHEADERTEMPLATE = '00000000-0000-0000-0000-000000000000' AND NOT EXISTS (SELECT 'X' FROM LD0V0PrintPartialData WHERE LD0V0PrintPartialData.FILEID = LD0VAA0PRINTTEMPLATE.PAGEHEADERTEMPLATE)) AS Result UNION
SELECT 'PrintingTemplateMissingHeaderInPartialHeaderRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VAA0PRINTTEMPLATE WHERE NOT LD0VAA0PRINTTEMPLATE.PAGEHEADERTEMPLATE = '00000000-0000-0000-0000-000000000000' AND NOT EXISTS (SELECT 'X' FROM LD0V0PrintPartialMetaData WHERE LD0V0PrintPartialMetaData.FILEID = LD0VAA0PRINTTEMPLATE.PAGEHEADERTEMPLATE)) AS Result UNION
SELECT 'PublishedDocumentMissingConcernPnrInPersonRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0A04 WHERE LD0V0A04.CONCERNSPNR > ' ' AND NOT EXISTS (SELECT 'X' FROM LD0V0A WHERE LD0V0A.PNR = LD0V0A04.CONCERNSPNR)) AS Result UNION
SELECT 'PublishedDocumentMissingInDocumentRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0A04 WHERE LD0V0A04.PUBLICATIONTYPE = 0 AND NOT LD0V0A04.PUBLICATIONKEY IN (SELECT LD0V0T41.DOKUMENTNR FROM LD0V0T41)) AS Result UNION
SELECT 'PublishedDocumentMissingToPnrInPersonRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0A04 WHERE LD0V0A04.TOPNR > ' ' AND NOT EXISTS (SELECT 'X' FROM LD0V0A WHERE LD0V0A.PNR = LD0V0A04.TOPNR)) AS Result UNION
SELECT 'RefugeeArrivalWayWrongTomDate' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0A770 WHERE TOMDAT = '00000000') AS Result UNION
SELECT 'RefugeeAtersoktillfalleMissingInRefugeeRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0A880 WHERE NOT EXISTS (SELECT 'X' FROM LD0V0A700 WHERE LD0V0A700.FLYKTNR = LD0V0A880.FLYKTNR)) AS Result UNION
SELECT 'RefugeeDataMissingInRefugeeRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0A770 WHERE NOT EXISTS (SELECT 'X' FROM LD0V0A700 WHERE LD0V0A700.FLYKTNR = LD0V0A770.FLYKTNR)) AS Result UNION
SELECT 'RefugeeMissingInPersonRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0A700 WHERE NOT EXISTS (SELECT 'X' FROM LD0VAA0PER WHERE LD0VAA0PER.PNR = LD0V0A700.PNR)) AS Result UNION
SELECT 'RefugeeReturnDataMissingInRefugeeRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0A780 WHERE NOT EXISTS (SELECT 'X' FROM LD0V0A700 WHERE LD0V0A700.FLYKTNR = LD0V0A780.FLYKTNR)) AS Result UNION
SELECT 'RefugeeSchablonCompensationMissingInRefugeeSchablonRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0A902 WHERE NOT EXISTS (SELECT 'X' FROM LD0V0A820 WHERE LD0V0A820.SCHABLNR = LD0V0A902.SCHABLNR)) AS Result UNION
SELECT 'RefugeeSchablonMissingInRefugeeRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0A820 WHERE NOT EXISTS (SELECT 'X' FROM LD0V0A700 WHERE LD0V0A700.FLYKTNR = LD0V0A820.FLYKTNR)) AS Result UNION
SELECT 'RefugeeUppehallMissingInRefugeeRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0A71 WHERE NOT EXISTS (SELECT 'X' FROM LD0V0A700 WHERE LD0V0A700.FLYKTNR = LD0V0A71.FLYKTNR)) AS Result UNION
SELECT 'RelationHaveEmptyStarOrEndDate' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0Y01 WHERE FOMDAT = ' ' OR TOMDAT = ' ' ) AS Result UNION
SELECT 'RelationHaveNoReference' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0Y01 WHERE NOT EXISTS(SELECT 'X' FROM LD0V0Y WHERE LD0V0Y.REFNR = LD0V0Y01.REFNR) ) AS Result UNION
SELECT 'ReminderHasNoPriorityOrStatus' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0BVK WHERE BEVAKSTATUS = 0 OR BEVAKPRIO = 0) AS Result UNION
SELECT 'RemissionDecisionMissingDecision' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYE WHERE LD0VYE.BESLNR2 > 0 AND NOT BESLNR2 IN (SELECT LD0VYE.BESLUTNR FROM LD0VYE)) AS Result UNION
SELECT 'ReportErrandExistForReportErrandData' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0REPORTDATA WHERE NOT EXISTS (SELECT 'X' FROM LD0V0REPORTERRAND  WHERE LD0V0REPORTERRAND.REPORTID = LD0V0REPORTDATA.REPORTID)) AS Result UNION
SELECT 'ReportInboxErrandWithoutErrandId' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0CONCERNREPORTERRAND WHERE ERRANDID = 0) AS Result UNION
SELECT 'RequirementsHasConnectionToSimplePlace' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0U61 WHERE LD0V0U61.ENKELPLATSNR > 0 AND NOT EXISTS(SELECT 'X' FROM LD0V0U70 WHERE LD0V0U61.ENKELPLATSNR = LD0V0U70.ENKELPLATSNR)) AS Result UNION
SELECT 'RequsitionInvoiceMissingPayment' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0G04 WHERE LD0V0G04.BETALNR > 0 AND NOT EXISTS (SELECT 'X' FROM LD0VYF WHERE LD0VYF.BETALNR = LD0V0G04.BETALNR)) AS Result UNION
SELECT 'RequsitionInvoiceMissingRequsition' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0G04 WHERE NOT LD0V0G04.REKVNR IN (SELECT LD0VYG.REKVNR FROM LD0VYG) AND FAKTRADNR > 200) AS Result UNION
SELECT 'RequsitionMissingJournalEvent' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYG WHERE LD0VYG.MAKULERAD = 0 AND NOT EXISTS (SELECT 'X' FROM LD0VYC11 WHERE LD0VYC11.HAGNR = LD0VYG.REKVNR AND HTYP = 170)) AS Result UNION
SELECT 'RequsitionMissingRequsitionPersons' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYG WHERE LD0VYG.INSNR > 0 AND NOT EXISTS (SELECT 'X' FROM LD0V0G01 WHERE LD0V0G01.REKVNR = LD0VYG.REKVNR)) AS Result UNION
SELECT 'RequsitionPersonsMissingInPersonRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0G01 WHERE NOT LD0V0G01.PNR IN (SELECT LD0V0A.PNR FROM LD0V0A)) AS Result UNION
SELECT 'RequsitionPersonsMissingRequsition' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0G01 WHERE NOT LD0V0G01.REKVNR IN (SELECT LD0VYG.REKVNR FROM LD0VYG) AND  REKVNR > 537) AS Result UNION
SELECT 'RequsitionWrongDates' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYG WHERE NOT LD0VYG.DATUM LIKE '19%' AND NOT LD0VYG.DATUM LIKE '20%') AS Result UNION
SELECT 'ResourceAllocationInpaymentMissingInPayment' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0N40 WHERE LD0V0N40.BETALNR > 0 AND NOT EXISTS (SELECT 'X' FROM LD0VYF WHERE LD0VYF.BETALNR = LD0V0N40.BETALNR)) AS Result UNION
SELECT 'ResourceAllocationInpaymentMissingResourceAllocation' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0N40 WHERE LD0V0N40.RESTILLDNR > 0 AND NOT EXISTS (SELECT 'X' FROM LD0VYN70 WHERE LD0VYN70.RESTILLDNR = LD0V0N40.RESTILLDNR)) AS Result UNION
SELECT 'ResourceAllocationInvoiceMissingPayment' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0N30 WHERE LD0V0N30.BETALNR > 0 AND NOT EXISTS (SELECT 'X' FROM LD0VYF WHERE LD0VYF.BETALNR = LD0V0N30.BETALNR)) AS Result UNION
SELECT 'ResourceAllocationInvoiceMissingPeriod' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0N30 WHERE LD0V0N30.FOMDAT = ' ' OR LD0V0N30.TOMDAT = ' ') AS Result UNION
SELECT 'ResourceAllocationInvoiceMissingResourceAllocation' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0N30 WHERE LD0V0N30.RESTILLDNR > 0 AND NOT EXISTS (SELECT 'X' FROM LD0VYN70 WHERE LD0VYN70.RESTILLDNR = LD0V0N30.RESTILLDNR)) AS Result UNION
SELECT 'ResourceAllocationPriceListMissingPeriod' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0N71 WHERE LD0V0N71.FOMDAT = ' ' OR LD0V0N71.TOMDAT = ' ') AS Result UNION
SELECT 'ResourceAllocationPriceListMissingResourceAllocation' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0N71 WHERE NOT EXISTS (SELECT 'X' FROM LD0VYN70 WHERE LD0VYN70.RESTILLDNR = LD0V0N71.RESTILLDNR)) AS Result UNION
SELECT 'ResourceAllocationsMissingEndDecision' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYN70 WHERE LD0VYN70.BESLUTNRSTOP > 0 AND NOT EXISTS (SELECT 'X' FROM LD0VYE WHERE LD0VYE.BESLUTNR = LD0VYN70.BESLUTNRSTOP)) AS Result UNION
SELECT 'ResourceAllocationsMissingProcentage' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYN70 WHERE LD0VYN70.PROCENT = 0) AS Result UNION
SELECT 'ResourceAllocationsMissingResourceAs' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYN70 WHERE NOT EXISTS (SELECT 'X' FROM LD0V0L01 WHERE LD0V0L01.RESURSSOMNR = LD0VYN70.RESURSSOMNR)) AS Result UNION
SELECT 'ResourceAllocationsMissingService' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYN70 WHERE NOT EXISTS (SELECT 'X' FROM LD0VYC20 WHERE LD0VYC20.INSNR = LD0VYN70.INSNR)) AS Result UNION
SELECT 'ResourceAllocationsMissingStartDecision' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYN70 WHERE LD0VYN70.BESLUTNRSTART > 0 AND NOT EXISTS (SELECT 'X' FROM LD0VYE WHERE LD0VYE.BESLUTNR = LD0VYN70.BESLUTNRSTART)) AS Result UNION
SELECT 'ResourceAllocationsMissingToOrFromDate' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYN70 WHERE LD0VYN70.FOMDAT = ' ' OR LD0VYN70.TOMDAT = ' ') AS Result UNION
SELECT 'ResourceAllocationWrongStartDates' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYN70 WHERE NOT LD0VYN70.FOMDAT LIKE '19%' AND NOT LD0VYN70.FOMDAT LIKE '20%') AS Result UNION
SELECT 'ResourceAllocationWrongStopDates' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYN70 WHERE NOT LD0VYN70.TOMDAT LIKE '19%' AND NOT LD0VYN70.TOMDAT LIKE '20%' AND NOT LD0VYN70.TOMDAT LIKE '99%') AS Result UNION
SELECT 'ResourceAreaMissingInAreaRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0L WHERE LD0V0L.OMRADE > 0 AND LD0V0L.OMRADE NOT IN(SELECT KOD FROM LD0V0Q01 WHERE LD0V0Q01.KODTYP = 'OMRÅDE')) AS Result UNION
SELECT 'ResourceAsMissingDates' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0L01 WHERE LD0V0L01.FOMDAT = ' ' OR LD0V0L01.TOMDAT = ' ') AS Result UNION
SELECT 'ResourceAsMissingInResourceRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0L01 WHERE NOT EXISTS (SELECT 'X' FROM LD0V0L WHERE LD0V0L.RESURSNR = LD0V0L01.RESURSNR)) AS Result UNION
SELECT 'ResourceBornCountryMissingInBornCountryRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0L WHERE LD0V0L.FODLAND > 0 AND LD0V0L.FODLAND < 9999 AND LD0V0L.FODLAND NOT IN(SELECT KOD FROM LD0V0Q01 WHERE LD0V0Q01.KODTYP = 'LAND')) AS Result UNION
SELECT 'ResourceCaseworkerMissingInCaseworkerRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0L05 WHERE NOT EXISTS (SELECT 'X' FROM LD0V0I WHERE LD0V0I.HAND = LD0V0L05.HAND)) AS Result UNION
SELECT 'ResourceCategoryMissingInCategoryRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0L WHERE LD0V0L.RESURSKAT NOT IN(SELECT KOD FROM LD0V0Q01 WHERE LD0V0Q01.KODTYP = 'RESURSKAT')) AS Result UNION
SELECT 'ResourceCitizenshipMissingInCitizenshipRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0L WHERE LD0V0L.MEDBSKAP > 0 AND LD0V0L.MEDBSKAP < 9999 AND LD0V0L.MEDBSKAP NOT IN(SELECT KOD FROM LD0V0Q01 WHERE LD0V0Q01.KODTYP = 'LAND')) AS Result UNION
SELECT 'ResourceCountyMissingInCountyRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0L WHERE LD0V0L.FOLKLAN > 0 AND LD0V0L.FOLKLAN < 9999 AND LD0V0L.FOLKLAN NOT IN(SELECT KOD FROM LD0V0Q01 WHERE LD0V0Q01.KODTYP = 'LÄN')) AS Result UNION
SELECT 'ResourceFamilyMissingInResourceRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0L03 WHERE NOT EXISTS (SELECT 'X' FROM LD0V0L WHERE LD0V0L.RESURSNR = LD0V0L03.RESURSNR)) AS Result UNION
SELECT 'ResourceLanguage1MissingInLanguageRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0L WHERE LD0V0L.KOMSPRAK1 > 0 AND LD0V0L.KOMSPRAK1 < 9999 AND LD0V0L.KOMSPRAK1 NOT IN(SELECT KOD FROM LD0V0Q01 WHERE LD0V0Q01.KODTYP = 'SPRAK')) AS Result UNION
SELECT 'ResourceLanguage2MissingInLanguageRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0L WHERE LD0V0L.KOMSPRAK2 > 0 AND LD0V0L.KOMSPRAK2 < 9999 AND LD0V0L.KOMSPRAK2 NOT IN(SELECT KOD FROM LD0V0Q01 WHERE LD0V0Q01.KODTYP = 'SPRAK')) AS Result UNION
SELECT 'ResourceLanguage3MissingInLanguageRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0L WHERE LD0V0L.KOMSPRAK3 > 0 AND LD0V0L.KOMSPRAK3 < 9999 AND LD0V0L.KOMSPRAK3 NOT IN(SELECT KOD FROM LD0V0Q01 WHERE LD0V0Q01.KODTYP = 'SPRAK')) AS Result UNION
SELECT 'ResourceMaritalStatusMissingInMaritalStatusRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0L WHERE LD0V0L.CIVKOD > 0 AND LD0V0L.CIVKOD < 9999 AND LD0V0L.CIVKOD NOT IN(SELECT KOD FROM LD0V0Q01 WHERE LD0V0Q01.KODTYP = 'CIVS')) AS Result UNION
SELECT 'ResourceMunicipalityMissingInMunicipalityRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0L WHERE LD0V0L.KOMMUN > 0 AND LD0V0L.KOMMUN < 9999 AND LD0V0L.KOMMUN NOT IN(SELECT KOD FROM LD0V0Q01 WHERE LD0V0Q01.KODTYP = 'KOMU')) AS Result UNION
SELECT 'ResourceNativeLanguageMissingInNativeLanguageRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0L WHERE LD0V0L.MODMAL > 0 AND LD0V0L.MODMAL < 9999 AND LD0V0L.MODMAL NOT IN(SELECT KOD FROM LD0V0Q01 WHERE LD0V0Q01.KODTYP = 'SPRAK')) AS Result UNION
SELECT 'ResourcePricesMissingInResourceRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0L04 WHERE NOT EXISTS (SELECT 'X' FROM LD0V0L WHERE LD0V0L.RESURSNR = LD0V0L04.RESURSNR)) AS Result UNION
SELECT 'ResourceStatusMissingInStatusRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0L WHERE LD0V0L.RESURSSTAT > 0 AND LD0V0L.RESURSSTAT NOT IN(SELECT KOD FROM LD0V0Q01 WHERE LD0V0Q01.KODTYP = 'RESURSSTAT')) AS Result UNION
SELECT 'ResourcesWithPnrThatShouldNotHavePnr' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0L WHERE LD0V0L.PNR > ' ' AND NOT RESURSKAT = 5) AS Result UNION
SELECT 'ResourceWordMissingInResourceRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0L02 WHERE NOT EXISTS (SELECT 'X' FROM LD0V0L WHERE LD0V0L.RESURSNR = LD0V0L02.RESURSNR)) AS Result UNION
SELECT 'ResponsibleInOpenEnrollmentPlanHasConnectionToResponsibleInEnrollment' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYU30 WHERE LD0VYU30.SLUTLIG = 0 AND LD0VYU30.TOMDAT = '99999999' AND NOT EXISTS(SELECT 'X' FROM LD0V0U12 WHERE LD0V0U12.ANSVARIGNR = LD0VYU30.ANSVARIGNR AND LD0V0U12.INSKRIVNINGSNR = LD0VYU30.INSKRIVNINGSNR)) AS Result UNION
SELECT 'SalaryMissingResourceAllocation' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0L50 WHERE LD0V0L50.RESTILLDNR > 0 AND NOT EXISTS (SELECT 'X' FROM LD0VYN70 WHERE LD0VYN70.RESTILLDNR = LD0V0L50.RESTILLDNR)) AS Result UNION
SELECT 'ScannedDocumentsConnectedToAllRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYT60 WHERE LD0VYT60.AEVERKNR > 0 AND LD0VYT60.INSNR > 0 AND LD0VYT60.AGARNR > 0 ) AS Result UNION
SELECT 'ScannedDocumentsWithAktualiseringMissingInAktualiseringRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYT60 WHERE LD0VYT60.DOKTYP = 14 AND LD0VYT60.AGARNR > 0 AND NOT EXISTS (SELECT 'X' FROM LD0VYH WHERE LD0VYH.AKTUALNR = LD0VYT60.AGARNR)) AS Result UNION
SELECT 'ScannedDocumentsWithAktualiseringNotSamePnrIInAktualiseringRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYT60 WHERE LD0VYT60.DOKTYP = 14 AND LD0VYT60.AGARNR > 0 AND NOT EXISTS (SELECT 'X' FROM LD0VYH WHERE LD0VYH.AKTUALNR = LD0VYT60.AGARNR AND LD0VYH.PNR = LD0VYT60.PNR)) AS Result UNION
SELECT 'ScannedDocumentsWithInvestigationMissingInInvestigationRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYT60 WHERE LD0VYT60.DOKTYP != 14 AND LD0VYT60.AEVERKNR > 0 AND NOT EXISTS (SELECT 'X' FROM LD0VYC WHERE LD0VYC.AEVERKNR = LD0VYT60.AEVERKNR)) AS Result UNION
SELECT 'ScannedDocumentsWithInvestigationNotSamePnrInInvestigationRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYT60 WHERE LD0VYT60.DOKTYP != 14 AND LD0VYT60.AEVERKNR > 0 AND NOT EXISTS (SELECT 'X' FROM LD0VYC WHERE LD0VYC.AEVERKNR = LD0VYT60.AEVERKNR AND LD0VYC.AKTPNR = LD0VYT60.PNR)) AS Result UNION
SELECT 'ScannedDocumentsWithOrganisationMissingInOrganisationRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYT60 WHERE LD0VYT60.ORGID > 0 AND LD0VYT60.ORGENHNR > ' ' AND NOT EXISTS (SELECT 'X' FROM LD0V0J01 WHERE LD0V0J01.ORGID = LD0VYT60.ORGID AND LD0V0J01.ORGENHNR = LD0VYT60.ORGENHNR)) AS Result UNION
SELECT 'ScannedDocumentsWithPnrMissingInPersonRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYT60 WHERE NOT EXISTS (SELECT 'X' FROM LD0V0A WHERE LD0V0A.PNR = LD0VYT60.PNR)) AS Result UNION
SELECT 'ScannedDocumentsWithServiceMissingInServiceRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYT60 WHERE LD0VYT60.DOKTYP != 14 AND LD0VYT60.INSNR > 0 AND NOT EXISTS (SELECT 'X' FROM LD0VYC20 WHERE LD0VYC20.INSNR = LD0VYT60.INSNR)) AS Result UNION
SELECT 'ScannedDocumentsWithServiceNotSamePnrInInServiceRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYT60 WHERE LD0VYT60.DOKTYP != 14 AND LD0VYT60.INSNR > 0 AND NOT EXISTS (SELECT 'X' FROM LD0VYC20 WHERE LD0VYC20.INSNR = LD0VYT60.INSNR AND LD0VYC20.AKTPNR = LD0VYT60.PNR)) AS Result UNION
SELECT 'ScannedDocumentsWithTypeNotInCodeRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYT60 WHERE LD0VYT60.SCATYP > 0 AND NOT EXISTS (SELECT 'X' FROM LD0V0Q01 WHERE LD0V0Q01.KODTYP = 'DOKTYP' AND LD0V0Q01.KOD = LD0VYT60.SCATYP)) AS Result UNION
SELECT 'SentInformationHasValidFatherhoodInformation' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT E56.* FROM LD0V0E56 E56 JOIN LD0V0E55 E55 ON E56.FSUPPGIFTNR = E55.FSUPPGIFTNR WHERE E55.BESLUTNR = 0 OR E55.HANDLNAMN = '' OR E55.HANDLEPOST = '' OR (E55.MODERPNR = '' AND E55.MODERFODDAT = '') OR E55.MODERFORNAMN = '' OR E55.MODEREFTERNAMN = '' ) AS Result UNION
SELECT 'ServiceCaseworkerHistoryMissingInCaseworkerRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0C22 WHERE NOT EXISTS (SELECT 'X' FROM LD0V0I WHERE LD0V0I.HAND = LD0V0C22.HAND)) AS Result UNION
SELECT 'ServiceCaseworkerHistoryMissingInOrganisationRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0C22 WHERE LD0V0C22.ORGENHNR > ' ' AND NOT EXISTS (SELECT 'X' FROM LD0V0J01 WHERE LD0V0J01.ORGID = LD0V0C22.ORGID AND LD0V0J01.ORGENHNR = LD0V0C22.ORGENHNR)) AS Result UNION
SELECT 'ServiceCaseworkerHistoryMissingPeriod' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0C22 WHERE LD0V0C22.FOMDAT = ' ' OR LD0V0C22.TOMDAT = ' ') AS Result UNION
SELECT 'ServiceCaseworkerHistoryMissingService' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0C22 WHERE NOT LD0V0C22.INSNR IN(SELECT LD0VYC20.INSNR FROM LD0VYC20)) AS Result UNION
SELECT 'ServiceCoCaseworkerHistoryMissingInCaseworkerRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0C22 WHERE LD0V0C22.MEDHAND > ' ' AND NOT EXISTS (SELECT 'X' FROM LD0V0I WHERE LD0V0I.HAND = LD0V0C22.MEDHAND)) AS Result UNION
SELECT 'ServiceCoCaseworkerHistoryMissingInOrganisationRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0C22 WHERE LD0V0C22.ORGENHNR2 > ' ' AND NOT EXISTS (SELECT 'X' FROM LD0V0J01 WHERE LD0V0J01.ORGID = LD0V0C22.ORGID AND LD0V0J01.ORGENHNR = LD0V0C22.ORGENHNR2)) AS Result UNION
SELECT 'ServiceInExecutionMissingInExecutionRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYC20 WHERE LD0VYC20.VERKNR > 0 AND NOT LD0VYC20.VERKNR IN(SELECT LD0VYC.AEVERKNR FROM LD0VYC WHERE LD0VYC.TMARK = 1)) AS Result UNION
SELECT 'ServiceInInvestigationMissingInInvestigationRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYC20 WHERE LD0VYC20.ARENDENR > 0 AND NOT LD0VYC20.ARENDENR IN(SELECT LD0VYC.AEVERKNR FROM LD0VYC WHERE LD0VYC.TMARK = 0)) AS Result UNION
SELECT 'ServiceMissingChain' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYC20 WHERE NOT LD0VYC20.INSNR IN(SELECT INSNR FROM LD0VYC10)) AS Result UNION
SELECT 'ServiceMissingDecision' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYC20 WHERE LD0VYC20.BESLUTNR = 0) AS Result UNION
SELECT 'ServiceMissingJournalEvent' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYC20 WHERE NOT EXISTS (SELECT 'X' FROM LD0VYC11 WHERE HTYP = 130 AND LD0VYC11.HAGNR = LD0VYC20.INSNR) AND NOT LD0VYC20.INSNR IN (900,1837,1839,2868)) AS Result UNION
SELECT 'ServiceMissingServicePersons' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYC20 WHERE NOT LD0VYC20.INSNR IN(SELECT LD0V0C21.INSNR FROM LD0V0C21)) AS Result UNION
SELECT 'ServiceOrganisationMissingInRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYC20 WHERE LD0VYC20.ORGENHNR > ' ' AND NOT EXISTS (SELECT 'X' FROM LD0V0J01 WHERE LD0V0J01.ORGID = LD0VYC20.ORGID AND LD0V0J01.ORGENHNR = LD0VYC20.ORGENHNR)) AS Result UNION
SELECT 'ServicePersonHistoryMissingService' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0C23 WHERE NOT LD0V0C23.INSNR IN(SELECT LD0VYC20.INSNR FROM LD0VYC20)) AS Result UNION
SELECT 'ServicePersonMissingInPersonRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYC20 WHERE NOT EXISTS (SELECT 'X' FROM LD0VAA0PER WHERE LD0VAA0PER.PNR = LD0VYC20.AKTPNR)) AS Result UNION
SELECT 'ServicePersonMissingService' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0C21 WHERE NOT LD0V0C21.INSNR IN(SELECT LD0VYC20.INSNR FROM LD0VYC20)) AS Result UNION
SELECT 'ServicePrivateAssetsMissingBalance' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VAA0Services WHERE PAYMENTTYPE = 2 AND NOT EXISTS (SELECT 'X' FROM LD0V0C24 WHERE LD0V0C24.INSNR = LD0VAA0Services.INSNR)) AS Result UNION
SELECT 'ServiceWithClosingOptionsButNotClosed' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYC20 WHERE (AVSLORSAKTYP > 0 OR AVSLORSAK > 0 OR AVSLORSAKSPEC > 0) AND TOMDAT = '99999999') AS Result UNION
SELECT 'ServiceWithWrongOrMissingPersonId' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYC20 WHERE LD0VYC20.AKTPNR = ' ' OR  LD0VYC20.AKTPNR LIKE '%*%') AS Result UNION
SELECT 'ServiceWithWrongPeriod' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYC20 WHERE LD0VYC20.FOMDAT = ' ' OR  LD0VYC20.TOMDAT = ' ') AS Result UNION
SELECT 'ServiceWrongStartDates' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYC20 WHERE NOT LD0VYC20.FOMDAT LIKE '19%' AND NOT LD0VYC20.FOMDAT LIKE '20%') AS Result UNION
SELECT 'ServiceWrongStopDates ' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0VYC20 WHERE NOT LD0VYC20.TOMDAT LIKE '19%' AND NOT LD0VYC20.TOMDAT LIKE '20%' AND NOT LD0VYC20.TOMDAT LIKE '99%') AS Result UNION
SELECT 'SocialStatusKlientMissingInPersonRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0M20 WHERE NOT EXISTS (SELECT 'X' FROM LD0V0A WHERE LD0V0A.PNR = LD0V0M20.PNR)) AS Result UNION
SELECT 'SocialStatusKlientMissingPersonId' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0M20 WHERE LD0V0M20.PNR = ' ') AS Result UNION
SELECT 'SocialStatusMissingInSocialStatusSituationRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0M22 WHERE NOT EXISTS (SELECT 'X' FROM LD0V0M21 WHERE LD0V0M21.SOCIALNR = LD0V0M22.SOCIALNR AND LD0V0M21.SOCSITNR = LD0V0M22.SOCSITNR)) AS Result UNION
SELECT 'SocialStatusSituationMissingInSocialStatusKlientRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0M21 WHERE NOT EXISTS (SELECT 'X' FROM LD0V0M20 WHERE LD0V0M20.SOCIALNR = LD0V0M21.SOCIALNR)) AS Result UNION
SELECT 'SortingOutCoordinationTypesMissingSortingOut' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0X11 WHERE NOT EXISTS (SELECT 'X' FROM LD0V0X WHERE LD0V0X.GALLNR = LD0V0X11.GALLNR)) AS Result UNION
SELECT 'SortingOutDossierMissingDossier' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0X30 WHERE NOT EXISTS (SELECT 'X' FROM LD0VYB WHERE LD0VYB.AKTNR = LD0V0X30.AKTNR)) AS Result UNION
SELECT 'SortingOutDossierMissingPerson' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0X30 WHERE LD0V0X30.DOSSIELED != ' ' AND NOT EXISTS (SELECT 'X' FROM LD0V0A WHERE LD0V0A.PNR = LD0V0X30.DOSSIELED)) AS Result UNION
SELECT 'SortingOutDossierMissingSortingOut' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0X30 WHERE NOT EXISTS (SELECT 'X' FROM LD0V0X WHERE LD0V0X.GALLNR = LD0V0X30.GALLNR)) AS Result UNION
SELECT 'SortingOutDossierSubDataMissingDossier' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0X31 WHERE NOT EXISTS (SELECT 'X' FROM LD0VYB WHERE LD0VYB.AKTNR = LD0V0X31.AKTNR)) AS Result UNION
SELECT 'SortingOutDossierSubDataMissingExecution' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0X31 WHERE LD0V0X31.KODTYP = 'JOURNALTYP' AND NOT EXISTS (SELECT 'X' FROM LD0VYC WHERE LD0VYC.AEVERKNR = LD0V0X31.GAGARNR)) AS Result UNION
SELECT 'SortingOutDossierSubDataMissingInvestigation' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0X31 WHERE LD0V0X31.KODTYP = 'UTREDTYP' AND NOT EXISTS (SELECT 'X' FROM LD0VYC WHERE LD0VYC.AEVERKNR = LD0V0X31.GAGARNR)) AS Result UNION
SELECT 'SortingOutDossierSubDataMissingService' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0X31 WHERE LD0V0X31.KODTYP = 'INSATS' AND NOT EXISTS (SELECT 'X' FROM LD0VYC20 WHERE LD0VYC20.INSNR = LD0V0X31.GAGARNR)) AS Result UNION
SELECT 'SortingOutDossierSubDataMissingSortingOut' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0X31 WHERE NOT EXISTS (SELECT 'X' FROM LD0V0X WHERE LD0V0X.GALLNR = LD0V0X31.GALLNR)) AS Result UNION
SELECT 'SortingOutExceptionTypesMissingSortingOut' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0X20 WHERE NOT EXISTS (SELECT 'X' FROM LD0V0X WHERE LD0V0X.GALLNR = LD0V0X20.GALLNR)) AS Result UNION
SELECT 'SortingOutTypesMissingSortingOut' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0X10 WHERE NOT EXISTS (SELECT 'X' FROM LD0V0X WHERE LD0V0X.GALLNR = LD0V0X10.GALLNR)) AS Result UNION
SELECT 'StatisticGroupHasAMissingCodetext' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0Q04 WHERE NOT EXISTS (SELECT 'X' FROM LD0V0Q01 WHERE LD0V0Q01.KODTYP = LD0V0Q04.KODTYP AND LD0V0Q01.KOD = LD0V0Q04.KOD)) AS Result UNION
SELECT 'StatisticGroupsHasEmptyPost' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0Q04 WHERE LD0V0Q04.STATGRP1 = 0 AND LD0V0Q04.STATGRP2 = 0 AND LD0V0Q04.STATGRP3 = 0 AND LD0V0Q04.STATGRP4 = 0 AND LD0V0Q04.STATGRP5 = 0) AS Result UNION
SELECT 'SurveyAdditionalDataHasConnectionToSurvey' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0U27 WHERE LD0V0U27.KARTLAGGNR >= 0 AND NOT EXISTS(SELECT 'X' FROM LD0V0U01 WHERE LD0V0U01.KARTLAGGNR = LD0V0U27.KARTLAGGNR)) AS Result UNION
SELECT 'SurveyEducationalLevelHasConnectionToSurvey' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0U28 WHERE LD0V0U28.KARTLAGGNR >= 0 AND NOT EXISTS(SELECT 'X' FROM LD0V0U01 WHERE LD0V0U01.KARTLAGGNR = LD0V0U28.KARTLAGGNR)) AS Result UNION
SELECT 'SurveyEducationBackgroundHasConnectionToSurvey' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0U20 WHERE LD0V0U20.KARTLAGGNR >= 0 AND NOT EXISTS(SELECT 'X' FROM LD0V0U01 WHERE LD0V0U01.KARTLAGGNR = LD0V0U20.KARTLAGGNR)) AS Result UNION
SELECT 'SurveyHomeDeviceLoanHasConnectionToSurvey' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0U43 WHERE LD0V0U43.KARTLAGGNR >= 0 AND NOT EXISTS(SELECT 'X' FROM LD0V0U01 WHERE LD0V0U01.KARTLAGGNR = LD0V0U43.KARTLAGGNR)) AS Result UNION
SELECT 'SurveyHousingSituationHasConnectionToSurvey' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0U26 WHERE LD0V0U26.KARTLAGGNR >= 0 AND NOT EXISTS(SELECT 'X' FROM LD0V0U01 WHERE LD0V0U01.KARTLAGGNR = LD0V0U26.KARTLAGGNR)) AS Result UNION
SELECT 'SurveyLanguageLevelHasConnectionToSurvey' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0U21 WHERE LD0V0U21.KARTLAGGNR >= 0 AND NOT EXISTS(SELECT 'X' FROM LD0V0U01 WHERE LD0V0U01.KARTLAGGNR = LD0V0U21.KARTLAGGNR)) AS Result UNION
SELECT 'SurveyLanguageLevelSFIHasConnectionToSurvey' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0U22 WHERE LD0V0U22.KARTLAGGNR >= 0 AND NOT EXISTS(SELECT 'X' FROM LD0V0U01 WHERE LD0V0U01.KARTLAGGNR = LD0V0U22.KARTLAGGNR)) AS Result UNION
SELECT 'SurveyMeritPortfolioHasConnectionToSurvey ' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0U24 WHERE LD0V0U24.KARTLAGGNR >= 0 AND NOT EXISTS(SELECT 'X' FROM LD0V0U01 WHERE LD0V0U01.KARTLAGGNR = LD0V0U24.KARTLAGGNR)) AS Result UNION
SELECT 'SurveyPostMissingPerson' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0U01 WHERE LD0V0U01.PERSONNR IN ('', ' ')) AS Result UNION
SELECT 'SurveySkillHasConnectionToSurvey' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0U25 WHERE LD0V0U25.KARTLAGGNR >= 0 AND NOT EXISTS(SELECT 'X' FROM LD0V0U01 WHERE LD0V0U01.KARTLAGGNR = LD0V0U25.KARTLAGGNR)) AS Result UNION
SELECT 'SurveyWorkExperienceHasConnectionToSurvey' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0U23 WHERE LD0V0U23.KARTLAGGNR >= 0 AND NOT EXISTS(SELECT 'X' FROM LD0V0U01 WHERE LD0V0U01.KARTLAGGNR = LD0V0U23.KARTLAGGNR)) AS Result UNION
SELECT 'TargetsMissingInGoalRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0M11 WHERE NOT EXISTS (SELECT 'X' FROM LD0V0M10 WHERE LD0V0M10.MALNR = LD0V0M11.MALNR)) AS Result UNION
SELECT 'TemplateMappingMissingFormInRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0Q02 WHERE LD0V0Q02.KODTYP = 'TYPDOK' AND  LD0V0Q02.KODTYP2 = 'TEMPLATE' AND LD0V0Q02.KOD > 0 AND NOT EXISTS (SELECT 'X' FROM LD0V0Q01 WHERE LD0V0Q01.KODTYP = 'TYPDOK' AND LD0V0Q01.KOD = LD0V0Q02.KOD)) AS Result UNION
SELECT 'TemplateMissingFooterInFormRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0Q01 WHERE LD0V0Q01.KODTYP = 'TEMPLATE' AND LD0V0Q01.XNUM7 > 0 AND NOT EXISTS (SELECT 'X' FROM LD0V0Q01 Q2 WHERE Q2.KODTYP = 'TYPDOK' AND Q2.KOD = LD0V0Q01.XNUM7)) AS Result UNION
SELECT 'TemplateMissingHeadInFormRegister' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT
FROM (SELECT * FROM LD0V0Q01 WHERE LD0V0Q01.KODTYP = 'TEMPLATE' AND LD0V0Q01.XNUM1 > 0 AND NOT EXISTS (SELECT 'X' FROM LD0V0Q01 Q2 WHERE Q2.KODTYP = 'TYPDOK' AND Q2.KOD = LD0V0Q01.XNUM1)) AS Result UNION
SELECT 'UnplacedChildWithOwnFeeThatDoesNotExist' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0D52 WHERE NOT EXISTS (SELECT 'X' FROM LD0V0D50  WHERE LD0V0D50.EGBERAKNR = LD0V0D52.EGBERAKNR)) AS Result UNION
SELECT 'VerifySystemVersioningAktualiseringDontReturnDuplicates' as TESTCASE   
,CASE WHEN COUNT(Result.AKTUALNR) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT AKTUALNR ,ENDTIME, COUNT(*) as RecordCount FROM LD0ApiAktualisering FOR SYSTEM_TIME CONTAINED IN ('2010-01-01 00:00:00.0000000', '9999-12-31 23:59:59.9999999') GROUP BY AKTUALNR ,ENDTIME  HAVING COUNT(*) > 1) AS Result UNION
SELECT 'VerifySystemVersioningCalculationDontReturnDuplicates' as TESTCASE   
,CASE WHEN COUNT(Result.BERAKNR) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT BERAKNR ,ENDTIME, COUNT(*) as RecordCount FROM LD0ApiCalculation FOR SYSTEM_TIME CONTAINED IN ('2010-01-01 00:00:00.0000000', '9999-12-31 23:59:59.9999999') GROUP BY BERAKNR ,ENDTIME  HAVING COUNT(*) > 1) AS Result UNION
SELECT 'VerifySystemVersioningDecisionDontReturnDuplicates' as TESTCASE   
,CASE WHEN COUNT(Result.BESLUTNR) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT BESLUTNR ,ENDTIME, COUNT(*) as RecordCount FROM LD0ApiDecision FOR SYSTEM_TIME CONTAINED IN ('2010-01-01 00:00:00.0000000', '9999-12-31 23:59:59.9999999') GROUP BY BESLUTNR ,ENDTIME  HAVING COUNT(*) > 1) AS Result UNION
SELECT 'VerifySystemVersioningExecutionDontReturnDuplicates' as TESTCASE   
,CASE WHEN COUNT(Result.AEVERKNR) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT AEVERKNR ,ENDTIME, COUNT(*) as RecordCount FROM LD0ApiExecution FOR SYSTEM_TIME CONTAINED IN ('2010-01-01 00:00:00.0000000', '9999-12-31 23:59:59.9999999') GROUP BY AEVERKNR ,ENDTIME  HAVING COUNT(*) > 1) AS Result UNION
SELECT 'VerifySystemVersioningInvestigationDontReturnDuplicates' as TESTCASE   
,CASE WHEN COUNT(Result.AEVERKNR) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT AEVERKNR ,ENDTIME, COUNT(*) as RecordCount FROM LD0ApiInvestigation FOR SYSTEM_TIME CONTAINED IN ('2010-01-01 00:00:00.0000000', '9999-12-31 23:59:59.9999999') GROUP BY AEVERKNR ,ENDTIME  HAVING COUNT(*) > 1) AS Result UNION
SELECT 'VerifySystemVersioningPaymentDontReturnDuplicates' as TESTCASE   
,CASE WHEN COUNT(Result.BETALNR) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT BETALNR ,ENDTIME, COUNT(*) as RecordCount FROM LD0ApiPayment FOR SYSTEM_TIME CONTAINED IN ('2010-01-01 00:00:00.0000000', '9999-12-31 23:59:59.9999999') GROUP BY BETALNR ,ENDTIME  HAVING COUNT(*) > 1) AS Result UNION
SELECT 'VerifySystemVersioningResourceAllocationDontReturnDuplicates' as TESTCASE   
,CASE WHEN COUNT(Result.RESTILLDNR) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT RESTILLDNR ,ENDTIME, COUNT(*) as RecordCount FROM LD0ApiResourceAllocation FOR SYSTEM_TIME CONTAINED IN ('2010-01-01 00:00:00.0000000', '9999-12-31 23:59:59.9999999') GROUP BY RESTILLDNR ,ENDTIME  HAVING COUNT(*) > 1) AS Result UNION
SELECT 'VerifySystemVersioningServiceDontReturnDuplicates' as TESTCASE   
,CASE WHEN COUNT(Result.INSNR) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT INSNR ,ENDTIME, COUNT(*) as RecordCount FROM LD0ApiService FOR SYSTEM_TIME CONTAINED IN ('2010-01-01 00:00:00.0000000', '9999-12-31 23:59:59.9999999') GROUP BY INSNR ,ENDTIME  HAVING COUNT(*) > 1) AS Result UNION
SELECT 'WorkAsCaseworkerWrongPeriod' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0I21 WHERE LD0V0I21.FOMDAT = ' ' OR LD0V0I21.TOMDAT = ' ') AS Result UNION
SELECT 'WorkAsWrongPeriod' as TESTCASE   
,CASE WHEN COUNT(*) > 0 THEN 'FAILED' ELSE 'PASS' END AS RESULT ,COUNT(*) AS FAILEDCOUNT    
FROM (SELECT * FROM LD0V0I20 WHERE LD0V0I20.FOMDAT = ' ' OR LD0V0I20.TOMDAT = ' ') AS Result
)FinalResult

SELECT * FROM #failedTests WHERE RESULT = 'FAILED'  
DROP TABLE #failedTests  
 

END
GO
GRANT ALL ON LD0SPDBTestCases TO LD0ROANV
GO