0
的SELECT部分在Moodle中使用「和」,我使用下面的腳本來拉一些數字 - 他們出來罰款:MOODLE在MySQL聲明
SELECT
qc.name,
q.category,
SUM(IF(qs.grade = "1",1,0)) AS Correct,
SUM(IF(qs.grade = "0",1,0)) AS Wrong
FROM
mdl_question_states qs,
mdl_quiz_attempts qa,
mdl_quiz qz,
mdl_course c,
mdl_question q,
mdl_question_categories qc
WHERE
qa.id = qs.attempt
AND qs.event = 6
AND qa.quiz = qz.id
AND ((qz.name = 'Pre-Test') OR (qz.name = 'Post-Test'))
AND qz.course = c.id
AND q.id = qs.question
AND q.category = qc.id
AND q.category > 601
GROUP BY q.category
ORDER BY qc.name
我的問題是這樣的:我想有一列(在SUM(IF ...'列)之後是'正確的-AND-預測試',後面跟着'正確的-AND-後測試'
什麼是語法做到這一點?
我認爲你從qz.name那裏得到前/後測試的東西? –
是的,這是正確的。 –
'sum(if(qs.grade ='1'and qz.name ='pre-test'),1,0))as cor_and_pre' –