Below it the table which contains Actual Count and Error Count for each ID.
USER_ID | Actual_Count | Error_Count
-----------+--------------------+---------------------
1345653 5 4
534140349 5 0
682527813 4 0
687612723 3 0
704318001 5 4
So if you look at the above scenario, For this 1345653 ID Out of 5, it has 4 errors, same with 704318001 ID, out of 5 it has 4 errors. And all other ID’s they didn’t have any errors as Error_Count is Zero for them. How can I calculate the total error percentage in SQL? Is it possible to calculate the total error percentage?
You can simply sum and divide the individual counts:
This will not work in all databases, because some (such as SQL Server) do integer division. The following does work: