mardi 4 août 2015

SQLITE How to Divide two count results in the same query

My current code:

SELECT VENDOR.[VENDOR_NAME], DEVICE.[DEVICE_NAME], DEVICE.[PK_DEVICE],MODELDEVICE.[FK_MODELDEVICE_DEVICE],

COUNT(RESULT.[FK_RESULT_COMMAND]) AS TOTAL_TESTS,
COUNT(case when TYPERESULT.[TYPERESULT_NAME]='ERROR' then 1 else null end) as ERROR,
COUNT(case when TYPERESULT.[TYPERESULT_NAME]='OK' then 1 else null end) as OK,
COUNT(case when TYPERESULT.[TYPERESULT_NAME]='SKIP' then 1 else null end) as SKIP,
COUNT(DISTINCT PK_COMMAND) AS COMMAND_COUNT, 
COUNT(DISTINCT RESULT_ORDER) AS RESULT_COUNT

The question is that I need another column with the result of dividing total ERROR results in TOTAL_TESTS results, and I don´t know how to do that

Aucun commentaire:

Enregistrer un commentaire