比较Google饼图中的两个SQL列值

比较Google饼图中的两个SQL列值,sql,charts,google-visualization,Sql,Charts,Google Visualization,总之,我试图比较两个SQL列的值,计算出百分比,然后在Google图表中显示这个输出 我有以下疑问 SELECT Count(lineAudited) as total_count, 121 as total_required FROM SMT_24_Point_Check.dbo.auditRecord which displays two columns, one value is 111 and the second column is 121, therefore the percent

总之,我试图比较两个SQL列的值,计算出百分比,然后在Google图表中显示这个输出

我有以下疑问

SELECT Count(lineAudited) as total_count, 121 as total_required FROM SMT_24_Point_Check.dbo.auditRecord which displays two columns, one value is 111 and the second column is 121, therefore the percentage is 91%, When I try to input this query into Google Chart, it's only displaying the second columns value
这显示了两列,一个值是111,第二列是121,因此百分比是91%,当我尝试将这个查询输入到Google ChStart时,它只显示第二列的值

  function drawChartCategory() {

        var data = google.visualization.arrayToDataTable([
          ['total_count', 'total_required'],
          <?php
          while($row = odbc_fetch_array($result1))
          {
               echo "['".$row["total_count'"]."', ".$row["total_required"]."],";
          }
          ?>
        ]);

        var options = {
            title: 'Total audits completed',
            width: 900,
            height: 500,
            backgroundColor: '#E8E8E8',
            pieSliceText: 'value',
            is3D: true
            };

        var chart = new google.visualization.PieChart(document.getElementById('piechartCategory'));

        chart.draw(data, options);
    }
函数drawChartCategory(){
var data=google.visualization.arrayToDataTable([
['total_count','total_required'],
检查图表

每行/每片应有两列。
第一列应该是切片名称的字符串,
第二个值是一个数字

因此,请尝试按如下方式格式化数据

'Required', 111
'Not Required', 10
您不能将总数作为一个部分添加,否则它将偏离百分比

      while($row = odbc_fetch_array($result1))
      {
           echo "['Required', ".$row["total_required"]."],";
           echo "['Not Required', ".($row["total_count'"] - $row["total_required"])."],";
      }

谢谢你的解释,我已经意识到了我的SQL查询的问题,所以我将它修改为一个联合,在“Cols”下显示两列“Cols”和“Vals”,我有“Total_Performed”和“Total_Total”,然后在“Vals”下我有111和121。但是我很难让饼图中的数据段显示为91%和9%,而不是da中每行的52%和48%ta table是饼图的一个切片,每个切片将表示为所有切片总数的百分比。如果总数为121,则两个切片值应为111和10。而不是111和121。