0 THEN time END) AS Q1, COUNT(CASE WHEN time <= 240 AND time > 120 THEN time END) AS Q2, COUNT(CASE WHEN time <= 360 AND time > 240 THEN time END) AS Q3, COUNT(CASE WHEN time > 360 THEN time END) AS Q4 FROM Datos GROUP by nroom"; $result3 = mysqli_query($connect, $query3); ?> Webslesson Tutorial | Make Simple Pie Chart by Google Chart API with PHP Mysql