tags:

views:

48

answers:

3

I have a testdata like this:

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;

The resultset I get is :

TC1 TIMEOUT
TC2 PASS
TC21    FAIL
TC3 PASS
TC4 PASS

Basically I want to see those testcases which never passed.

Any way to do it?

Thanks.

+4  A: 

This will give you all the test case names that don't have any pass results:

SELECT DISTINCT TESTCASE FROM SELECT_PASS
 WHERE TESTCASE NOT IN (SELECT TESTCASE FROM SELECT_PASS WHERE RESULT = 'PASS')
Phil Ross
THIS IS EXACTLY WHAT I WANTED.
JPro
+1  A: 
SELECT 
  TESTCASE, 
  MAX(RESULT) RESULT
FROM 
  SELECT_PASS  
GROUP BY 
  TESTCASE
HAVING 
  TESTCASE != 'PASS'
used2could
sorry, had to update the SQL
used2could
+1, it should be 'HAVING RESULT...', and this only works if the values are ordered (e.g. numeric).
stereofrog
It get the resultset as `TC1` `TIMEOUT` `TC2` `PASS` `TC21` `FAIL` `TC3` `PASS` `TC4` `PASS` TC1 is pass in the begining itself
JPro
A: 

I'd use numeric values for result, with pass being the greatest (or lowest), and the MAX query:

SELECT TESTCASE, MAX(RESULT) AS r FROM SELECT_PASS  GROUP BY TESTCASE HAVING r < 999

where 999 is the numeric value for PASS.

stereofrog
this did not work out either
JPro
sorry to hear that
stereofrog
but I learnt a new value for PASS. Thx
JPro