I am making a report and need to count and display the number plus the percentage for the total count. With this code I already count. Is it possible to display the percentage next to it using sql and php?
$sql = "SELECT
customer.country,
COUNT(*) AS count
FROM
customer
INNER JOIN
booking ON booking.customer_id = customer.id
WHERE
(checkin >= '$datainicialsql' AND checkout <= '$datafinalsql')
GROUP BY country";
$query = mysql_query($sql);
$w = 0;
while ($result = mysql_fetch_assoc($query))
{
echo $result['country'] . " - " . $result['count'] . "<br/>";
}
I wanted to do an output like this:
BR 20 (20%)
IT 40 (40%)
PT 40 (40%)