我有一个像这样的测试数据:
DROP TABLE SELECT_PASS;
CREATE TABLE SELECT_PASS(ID INT(20),TESTCASE VARCHAR(20),RESULT VARCHAR(20));
INSERT INTO SELECT_PASS VALUES(1,"TC1","PASS");
INSERT INTO SELECT_PASS VALUES(2,"TC2","PASS");
INSERT INTO SELECT_PASS VALUES(3,"TC3","INCONC");
INSERT INTO SELECT_PASS VALUES(4,"TC1","FAIL");
INSERT INTO SELECT_PASS VALUES(5,"TC21","FAIL");
INSERT INTO SELECT_PASS VALUES(6,"TC4","PASS");
INSERT INTO SELECT_PASS VALUES(7,"TC3","PASS");
INSERT INTO SELECT_PASS VALUES(8,"TC2","PASS");
INSERT INTO SELECT_PASS VALUES(9,"TC1","TIMEOUT");
SELECT TESTCASE, MAX(RESULT) FROM SELECT_PASS GROUP BY TESTCASE;
我得到的结果集是:
TC1 TIMEOUT
TC2 PASS
TC21 FAIL
TC3 PASS
TC4 PASS
基本上我想看看那些从未过去的测试用例。
有什么办法吗?
感谢。
答案 0 :(得分:4)
这将为您提供所有没有任何传递结果的测试用例名称:
SELECT DISTINCT TESTCASE FROM SELECT_PASS
WHERE TESTCASE NOT IN (SELECT TESTCASE FROM SELECT_PASS WHERE RESULT = 'PASS')
答案 1 :(得分:1)
SELECT
TESTCASE,
MAX(RESULT) RESULT
FROM
SELECT_PASS
GROUP BY
TESTCASE
HAVING
TESTCASE != 'PASS'
答案 2 :(得分:0)
我会使用数值作为结果,传递是最大的(或最低的),以及MAX查询:
SELECT TESTCASE, MAX(RESULT) AS r FROM SELECT_PASS GROUP BY TESTCASE HAVING r < 999
其中999是PASS的数值。