一、需求
用户答题,共3道,必须3题都答完才能提交。
目的:要查询用户答对了几题,答错了几题。(当然此处可以只查答对的题目数,用3减即得答错题的题目数)
二、sql
select * from (select count(1) rightCount from (select * from (select * from mic_td_exercise_push_problem mp where mp.push_id = 347 order by mp.create_time desc) where rownum <= 3) t1 where t1.is_correct = 1), (select count(1) wrongCount from (select * from (select * from mic_td_exercise_push_problem mp where mp.push_id = 347 order by mp.create_time desc) where rownum <= 3) t1 where t1.is_correct = 2)
将两个查询结果进行联合查询,就得到了一条记录,两个向要的结果。
时间: 2024-10-04 03:02:13