lundi 4 avril 2016

Sqlite GROUP query

I need to group result of test "PASS" / "FAIL" for serial number. If one or more Test "FAIL" the result for the serial number is "FAIL"

CREATE TABLE IF NOT EXISTS Test
(
    Id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
    Product TEXT NOT NULL,
    Serial INTEGER NOT NULL,
    Result TEXT NOT NULL,
    NTest INTEGER NOT NULL
    );

INSERT INTO Test (Product, Serial, Result,Ntest)
VALUES ('Sample', 1, 'PASS',1),('Sample', 1, 'FAIL',2),
('Sample', 1, 'PASS',3),('Sample', 2, 'PASS',1),
('Sample', 2, 'PASS',2),('Sample', 2, 'PASS',3);

SELECT Product,Serial,Result
FROM test
GROUP BY Serial;

DELETE FROM test;
DROP TABLE test;

I need this :

"Sample"    "1" "FAIL"
"Sample"    "2" "PASS"

but result are:

"Sample"    "1" "PASS"
"Sample"    "2" "PASS"

thanks

Aucun commentaire:

Enregistrer un commentaire