我正在尝试编写SQL以确定两个百分比。问题是我的百分比是根据RUN表中的所有表条目计算的。我希望我的百分比基于所选记录的“总和”和“计数”。我希望这是有道理的。
SELECT
TEST.TS_NAME /*Test.Test Name*/ AS "Test Name" ,
Count(TEST.TS_NAME) As "Executions" ,
SUM(RUN.RN_DURATION) AS "Durtion Summary" ,
Round(((count(RUN.RN_TEST_ID)/(SELECT count(RUN.RN_TEST_ID) FROM RUN )))*100,2)as "Execution Percentage" ,
Round(((SUM(RUN.RN_DURATION)/(SELECT SUM(RUN.RN_DURATION) FROM RUN)))*100,2)as "Duration Percentage"
FROM
RUN INNER JOIN TEST ON RUN.RN_TEST_ID = TEST.TS_TEST_ID
WHERE
TEST.TS_TYPE = 'QUICKTEST_TEST' AND (TEST.TS_NAME Not Like 'FIN - Revenue Consignment%' AND TEST.TS_NAME NOT LIKE 'WMIM - 053 ZIGO POSTO - Type UB, ZUS, ZM, ZP ZS - Test Case 49')
group by TEST.TS_NAME
having count(TEST.TS_NAME) > 1
Order by "Duration Percentage" DESC, "Execution Percentage" DESC