我想列出总投票差,公平,好,vgood,优秀,是,否从我的调查结果表,但查询只有一个时间循环。
这是调查结果表。
这是查询结果
SELECT
categori.s_categori_id,
categori.categori_name_en,
categori.categori_name_ar,
categori.categori_type,
question.survey_id,
question.question_en,
question.question_ar,
SUM(result.poor) AS poor,
SUM(result.fair ) AS fair,
SUM(result.good) AS good,
SUM(result.vgood) AS vgood,
SUM(result.excellent) AS excellent,
SUM(result.yes) AS yes,
SUM(result.no) As no,
result.comment
FROM
survey_categori AS categori
INNER JOIN survey_questions AS question ON categori.s_categori_id =
question.s_categori_id
INNER JOIN survey_result AS result ON result.s_question_id =
question.survey_id
WHERE
categori.survey_type = 'class'
GROUP BY
question.survey_id
2条答案
按热度按时间3pvhb19x1#
我想从我的调查结果表中列出总票数:差、一般、好、好、优秀、是、否
听起来你想要整个调查的总数。如果是这样的话,你不应该使用
GROUP BY
. 要获得一行:你会用
GROUP BY
如果您想在结果集中有多行。然后,在GROUP BY
将(通常)添加到SELECT
. 例如,如果您希望每个调查有一行,则必须:9jyewag02#
您必须在我在查询中添加的字段下面添加group by