PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I'm trying to get the percentage of each person who performed work, but the total percentage is never 100%. It shows up as 99%. I've been struggling with this for quite some time. Does anyone have any helpful hints which may help resolve my issue?
<?PHP
$string = "SELECT COUNT(Therapist) AS Count, Round(100*COUNT(Therapist)/Count2,0) + '%' AS Percentage, Date_Of_Entry, Therapist, SUM(BILL_TIME) AS BILL_TOTAL
FROM tblprivatepracticedetails,
(SELECT COUNT( Therapist ) AS Count2
FROM tblprivatepracticedetails
) AS c
WHERE Date_Of_Entry Between '$FromDate' And '$ToDate' GROUP BY Therapist WITH ROLLUP";
$query = mysql_query($string) or die (mysql_error());
?>
I would guess that it's just a rounding error, which is to be expected when you round to 0 digits, as you are doing. The actual result of dividing one count of therapists by the count of all the therapists might be numbers like 33.333333333 or 16.666666667 but when you round them and add them up, they are unlikely to ever total precisely 100.