I am using below query to count two different values in a row and its working perfectly.
Seek your help in finding how I can make the query to show output in percentage values
Query is
SELECT `Machine`,
SUM(CASE WHEN `state` = 'UnHealthy' THEN 1 ELSE 0 END) 'Red'
, SUM(CASE WHEN `state` = 'Healthy' THEN 1 ELSE 0 END) 'Green'
, SUM(CASE WHEN `state` = 'UnHealthy' or `state` = 'Healthy' THEN 1 ELSE 0 END) 'Total'
FROM Report Where date(`TOI`) >= DATE(NOW()) - INTERVAL 7 DAY
Group by `Machine`
Output is
Machine Red Green Total
Node1 3 14 17
Node2 0 3 3
Node3 4 6 10
How can I make the above result to come in percentage, like below
Machine Red Green Total
Node1 20% 80% 17
Node2 25% 75% 3
Node3 50% 50% 10
Which later I want to bootstrap to PHP as progressbar.
Thanks,