OpenTestMapper.xml 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
  3. <mapper namespace="com.ssj.service.mapper.OpenTestMapper">
  4. <select id="countResult" resultType="com.ssj.bean.mybatis.OpenTestMBDto" parameterType="java.util.Map">
  5. select count(1) total,
  6. sum(case when accuracy_rate &lt; #{map.accuracyRate} then 1 else 0 end) accuracyLower,
  7. sum(case when `time` > #{map.time} then 1 else 0 end) timeLower
  8. from tb_test_result
  9. where grade = #{map.grade}
  10. and subject = #{map.subject}
  11. and version = #{map.version}
  12. </select>
  13. <select id="findRankingResult" resultType="com.ssj.bean.mybatis.OpenTestMBDto" parameterType="java.util.Map">
  14. SELECT @rownum := @rownum + 1 AS rankingNo,
  15. t.score,
  16. (select name from tb_test_user where user_id = t.user_id limit 1) name
  17. FROM
  18. ( SELECT @rownum := 0 ) r,
  19. tb_test_result t
  20. where t.grade = #{map.grade}
  21. and t.subject = #{map.subject}
  22. and t.is_delete = 0
  23. <if test="map.version != null and map.version != '' ">
  24. and t.version = #{map.version}
  25. </if>
  26. <if test="map.unit != null and map.unit != '' ">
  27. and t.unit = #{map.unit}
  28. </if>
  29. <if test="map.type != null and map.type != '' ">
  30. and t.type = #{map.type}
  31. </if>
  32. order by t.score desc,t.create_time
  33. </select>
  34. </mapper>