My understanding of the requirement is not entirely clear. In my review while working with your code, it seems the expression required to get the rate or Percent Sensitive or Resistant of each Bug/Bicho vs ATB based on test results was/is
%S of Bug X with ATB Y = Number of S results/(Number S Results +Number of R results) * 100 and
%R of Bug X with ATB Y = Number of R results/(Number S Results +Number of R results) * 100
I did not have any success to get the final result with SQL queries. I could get pieces, as I showed in my previous post, but could not get all the pieces for all the Bug/ATB combinations and the proper count of test Results. Somebody else more familiar with SQL queries may be able to avoid the table and get the solution directly.
I decided to identify a simple format that would put the necessary pieces together. I had no luck with a variety of queries so I decided to:
Code:
=create a table (JackTestCopy) of the basic need with fields for:
--BugID
--ATBID
--result -----your sensibilidade
--resultR -----number of R results
--resultS -----number of S results
--NumTests
and populate this table with a few queries of your existing data. I did identify those Bug/ATM combinations where test results were partly S and partly R.
Code:
SELECT jacktest.ATBId, jacktest.BichoId, count(*) AS cnt
FROM (SELECT jacktest.ATBId, jacktest.BichoId, jacktest.RESULT, Sum(jacktest.numtests) AS TotTest FROM jacktest GROUP BY jacktest.ATBId, jacktest.BichoId, jacktest.RESULT) AS [%$##@_Alias]
GROUP BY jacktest.ATBId, jacktest.BichoId
HAVING count(*) >1;
These were:
ATBId |
BichoId |
cnt |
ERI |
SAUREUS |
2 |
ERI |
SEPIDERM |
2 |
ERI |
SHAEMOL |
2 |
OXA |
SEPIDERM |
2 |
Here is a graphic showing some of the data in table JackTestCopy.
By getting the R and S numbers for each Bug/ATB combination into a single table (or query), the %S and %R are easily derived with a query.
Here is my query against the populated table (you could get the true names of Bicho and ATB and/or other info by adding the relevant tables to this query)
Code:
SELECT JackTestCOPY.ATBId
, JackTestCOPY.BichoId
, JackTestCOPY.resultR
, JackTestCOPY.resultS
, JackTestCOPY.NumTests
, Round([resultR]/[numtests]*100,2) AS PctR
, Round([resultS]/[Numtests]*100,2) AS PctS
FROM JackTestCOPY;
Here is a graphic of part of that query output.
Please note that the draft model I provided in Feb 2017 was intended as a DRAFT-- a starting point to be tested and adjusted as needed.
Por favor, note que o modelo preliminar que eu forneci em fevereiro de 2017 foi planejado como um ponto de partida para ser testado e ajustado necessário.
It's unfortunate that there was a long delay before working with that model. The software that I created that model with is no longer available as a free/community edition. I have removed that software and models created with it from my system. I do keep jpg/png of some models.
You may find the links and materials re Database Planning and Design at this page useful.
Good luck with your project.