Detta är det mesta av svaret, som vi bestämde i den interaktiva chatten:
SELECT A.projectName as PARENT,COUNT(A.PROJECTNAME) AS PARENTPROJECTCOUNT,
B.ProjectName as CHILD, COUNT(B.PROJECTNAME) AS CHILDPROJECT from psprojectitem
a INNER JOIN psProjectItem B
ON a.objecttype = b.objecttype
AND a.objectid1 =b.objectid1
AND a.objectvalue1 = b.objectvalue1
AND a.objectid2 = b.objectid2
AND a.objectvalue2 = b.objectvalue2
AND a.objectid3 = b.objectid3
AND a.objectvalue3 = b.objectvalue3
AND a.objectid4 = b.objectid4
AND a.objectvalue4 = b.objectvalue4
WHERE A.projectname in
(SELECT ProjectName from psProjectDefn WHERE lastupdoprid <> 'pplsoft')
AND a.projectname <> B.projectName
and A.PROJECTNAME = 'AAAA_JOB_KJ'
ORDER BY B.PROJECTNAME