一、需求

  用户答题,共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)

将两个查询结果进行联合查询,就得到了一条记录,两个向要的结果。

相关文章:

  • 2022-12-23
  • 2022-02-15
  • 2021-09-07
  • 2021-09-07
  • 2021-12-10
  • 2022-12-23
  • 2021-08-14
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-09-07
  • 2022-12-23
  • 2022-12-23
  • 2021-09-25
  • 2021-06-03
相关资源
相似解决方案