SELECT A.DBNAME , A.USERID , A.PTIASPSPVERS , A.PTIASPPRDCD , ROUND(PART/TOTAL , 3) FROM ( SELECT DBNAME , USERID , PTIASPSPVERS , PTIASPPRDCD , COUNT(PTIASPRPTNO) AS TOTAL FROM PS_PTIASPRPTTYPEVW WHERE PTIASPAPPLIED <> 'O' GROUP BY DBNAME, USERID, PTIASPSPVERS ,PTIASPPRDCD ) A , ( SELECT DBNAME , USERID ,PTIASPSPVERS , PTIASPPRDCD , COUNT(PTIASPAPPLIED) AS PART FROM PS_PTIASPRPTTYPEVW WHERE PTIASPAPPLIED = 'P' GROUP BY DBNAME, USERID, PTIASPSPVERS, PTIASPPRDCD ) B WHERE A.DBNAME = B.DBNAME AND A.USERID = B.USERID AND A.PTIASPSPVERS = B.PTIASPSPVERS AND A.PTIASPPRDCD = B.PTIASPPRDCD ORDER BY B.DBNAME, B.PTIASPSPVERS
|