WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'GROUP BY s.student_id
) as emps' at line 18]
SELECT
SUM(if(positive_ct>0,1,0)) as positive_ct,
SUM(if(negative_ct>0,1,0)) as negative_ct,
SUM(if(no_change_ct>0,1,0)) as no_change_ct
FROM (
SELECT
s.student_id,
sum(if(q.answer_after>q.answer_before,1,0)) as positive_ct,
sum(if(q.answer_after<q.answer_before,1,0)) as negative_ct,
sum(if(q.answer_after=q.answer_before,1,0)) as no_change_ct
FROM ey3_stru u
JOIN ey3_surveys s ON u.user = s.student_id
JOIN ey3_survey_questions q ON q.survey_id = s.id
WHERE q.question_type IN ('M')
AND u.user != u.parent_user
AND s.training_id =
GROUP BY s.student_id
) as emps