sql 语句查询5个选择题选择ABCD正确率和错误率
发布网友
发布时间:2022-05-02 08:59
我来回答
共2个回答
热心网友
时间:2022-05-02 10:29
create table testquest(qid integer,selected integer,actual integer);/*qid为题号,selected为自选,actual为答案,1,2,3,4为abcd*/
insert into testquest values(1,1,1);
insert into testquest values(2,1,2);
insert into testquest values(3,1,3);
insert into testquest values(4,1,2);
insert into testquest values(5,1,3);
select count(a.qid),sum(a.currect),sum(a.error) from
(
select qid,case when selected=actual then 1 else 0 end as currect,case when selected<>actual then 1 else 0 end as error from testquest
) a
热心网友
时间:2022-05-02 11:47
楼主,你好!你把问题描述详细点,我看看