Estoy trabajando con highcharts, lo que deseo hacer es que los agrupe por fecha y los separe dependiento de la respuesta (SI o NO)
pregunta1 created_at NO 2019-02-24 SI 2019-02-24 NO 2019-05-24 NO 2019-05-24
Que realice el conteo de cada mes y muestre el total en una barra de la respuesta Si y otra barra de la respuesta NO, aunque pertenezcan o no al mismo mes.
En esta consulta efectivamente me agrupa por fecha pero no respeta las respuestas, es decir; hay un SI y NO con la fecha 2019-02-24 pero no las separa por la respuesta SI o No (en el conteo encuentra dos registros con las mismas fechas).
Codigo grafica
<?php require_once("graphic_connection.php"); ?> <!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Gráfica | Encuesta</title> <body> <img src="images/logos.png" alt="Logo" title="Logo"/> </body> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script> <style type="text/css"> #container { height: 700px; min-width: 510px; max-width: 900px; margin: 0 auto; } </style> <script type="text/javascript"> $ (function () { $ ('#container').highcharts({ chart: { type: 'column', margin: 140, options3d: { enabled: true, alpha: 10, beta: 10, depth: 70 } }, title: { text: 'Gráfica | Encuesta' }, subtitle: { text: '' }, plotOptions: { column: { depth: 25 } }, xAxis: { categories: [ <?php $ sql=mysql_query("SELECT pregunta1, COUNT(*) total FROM encuesta where month(created_at) GROUP BY month(created_at) ORDER BY total DESC"); while ($ res=mysql_fetch_array($ sql)){ ?> ['<?php echo $ res['pregunta1'] ?>'], <?php } ?> ] }, yAxis: { title: { text: null } }, series: [{ name: '¿Nuestro ingeniero de soporte le ofreció una solución / respuesta de manera oportuna?', data: [ <?php $ sql=mysql_query("SELECT pregunta1, COUNT(*) total FROM encuesta GROUP BY month(created_at) ORDER BY total DESC"); while ($ res=mysql_fetch_array($ sql)){ ?> [<?php echo $ res['total']?> ], <?php } ?> ] }] }); }); </script> </head> <body> <script src="Highcharts-4.1.5/js/highcharts.js"></script> <script src="Highcharts-4.1.5/js/highcharts-3d.js"></script> <script src="Highcharts-4.1.5/js/modules/exporting.js"></script> <div id="container" style="height: 400px"></div> </body> </html>