Specialty Performance on PreTest Questions
Infectious Disease 25% (37/148)
Internal Medicine 17% (2/12)
Pathology 20% (3/15)
这是一个考试数据库。我想要的是按专业列出的百分比列表。第一个数字代表得出问题的总人数(37)。第二个是完全回答它的总数,对或错(148)
预测试题 预测试包含一组模块和问题
module 2 questions (1,2),
module 3 questions (1,2,3),
module 4 question (1),
module 5 question (1),
module 6 question (1)
Where子句 这是where子句的一部分。这是我们计算“正确”问题的方式:
(q.type = 'PASS_FAIL' and e.correct = 'T' )
以下是我们总共回答过的人的部分:
(q.type = 'PASS_FAIL' )
我最好的尝试 我确信我们不能将整套测试前问题作为一个查询来执行此操作 按问题这样做是可以的。我认为参数化查询我们放入模块和问题数字就可以了。
我能想到的最好的是使用两个单独查询的专业总数。我无法弄清楚如何使这个单一查询,也不能链接百分比计算(每个专业)。有可能????
我是知识的海绵! -Thanks
CREATE
ALGORITHM = UNDEFINED
VIEW `PretestTotals_M2_Q1_by_specialty_degree`
AS
(select a.specialty, count( e.question ) as totals_M2_Q1
FROM Exam as e
JOIN
Questions as q using(module,question) join Accounts a using (user_id)
WHERE
(q.type = 'PASS_FAIL' )
and
(e.module = 2 and e.question = 1)
group by a.specialty
);
CREATE
ALGORITHM = UNDEFINED
VIEW `PretestCorrect_M2_Q1_by_specialty_degree`
(select a.specialty,a.degree, count( e.question ) as Correct_M2_Q1
FROM Exam as e
JOIN
Questions as q using(module,question) join Accounts a using (user_id)
WHERE
(q.type = 'PASS_FAIL' and e.correct = 'T' )
and
(e.module = 2 and e.question = 1)
group by a.specialty
);
帐户表 [典型的东西,但我注意到了对此查询至关重要的字段]
user_id,
degree, #college degree as selected from a dropdown on a form
specialty #medical specialization
考试表 [*记录在线考试的结果。他们的user_id,模块和问题编号,尝试计数器,他们的实际答案以及该答案的正确性T / F *]
user_id,
module,
question,
attempt,
answer,
correct
问题表 [*记录模块编号,问题编号,实际问题的文本和问题的“类型”。三种可能的类型(ALWAYS_PASS,PASS_FAIL,POLLING)作为枚举*]
module,
question
text,
type