Ajax,
Did the code you suggested work on your machine? I couldn't get it to
work on mine without adding some GROUP BY statements:
SELECT A.pin, A.failed,b.attempts,(cast(A.failed as float)/cast(B.attempts
as float)*100) as failrate
FROM
(SELECT pin,count(pin)as failed from eventlog where pass_fail = 0 GROUP BY
pin) A,
(SELECT pin,count(pin) as attempts from eventlog GROUP BY pin) B
WHERE
A.pin = B.pin
As an aside, I tested our 2 suggested methods on a fictional dataset (4000
rows) to see the performance difference. Interestingly the difference
wasn't anywhere near as great as I expected - at around 15%.
cheers,
andy