从SQL语句中获得总和的百分比 [英] Getting percentage from overall sum in a SQL statement

查看:134
本文介绍了从SQL语句中获得总和的百分比的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个sql语句,它获取数据库名称响应中每个部分的总和,我使用了一个内部joing语句,因为表dqa_questions是已定义所有部分的地方,我的问题是我想得到总和的百分比%,但我无法找到方法,找到我的下面的sql语句,只是获得总和



我尝试过:



<?php 

$ query4 = mysqli_query($ conn,SELECT SUM(`Response` )作为总的来自`响应'r INNER JOIN dqa_questions q ON(r.question_fk = q.short_form)和q.Section ='数据可用性');
$ row = mysqli_fetch_array($ query4);
echo $ row ['total'];

?>

解决方案

query4 = mysqli_query(


conn,SELECT SUM(`Response`)as total FROM`response` r INNER JOIN dqa_questions q ON(r.question_fk = q.short_form)AND q.Section ='Data availability');


行= mysqli_fetch_array(

I have an sql statement that gets the overall sum of each section in a database name responses, i there have used an inner joing statement as the table dqa_questions is where all the sections have been defined, my problem is i want to get the percentage % from the sum but i cant figure a way, find my below sql statement which just gets the sum

What I have tried:

<?php

               $query4=mysqli_query($conn, "SELECT SUM(`Response`) as total FROM `responses` r INNER JOIN dqa_questions q ON(r.question_fk=q.short_form) AND q.Section='Data availability'");
               $row=mysqli_fetch_array($query4);
               echo $row['total'];

              ?>

解决方案

query4=mysqli_query(


conn, "SELECT SUM(`Response`) as total FROM `responses` r INNER JOIN dqa_questions q ON(r.question_fk=q.short_form) AND q.Section='Data availability'");


row=mysqli_fetch_array(


这篇关于从SQL语句中获得总和的百分比的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆