关于答题的sql,查看十道题,某道题,选择某个选项的几率是多少。 round()函数,后面可以带数字,表示取小数点后几位。
select ifnull(ROUND((select count(1) from
.cpn_511_video_prize_giving_memberrecord
where `vpKey` = #{key} and question_#{num} = #{rightAnswer})*100/count(1),2),0)
from xxx.cpn_511_video_prize_giving_memberrecord
where `vpKey` = #{key}