QueryCodeMapper.xml 65 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300
  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.e3.zl.wc.dao.QueryCodeMapper">
  4. <resultMap id="BaseResultMap" type="com.e3.zl.wc.bo.SevenStarCodeBo">
  5. <result column="first0" jdbcType="INTEGER" property="first0" />
  6. <result column="first1" jdbcType="INTEGER" property="first1" />
  7. <result column="first2" jdbcType="INTEGER" property="first2" />
  8. <result column="first3" jdbcType="INTEGER" property="first3" />
  9. <result column="first4" jdbcType="INTEGER" property="first4" />
  10. <result column="first5" jdbcType="INTEGER" property="first5" />
  11. <result column="first6" jdbcType="INTEGER" property="first6" />
  12. <result column="first7" jdbcType="INTEGER" property="first7" />
  13. <result column="first8" jdbcType="INTEGER" property="first8" />
  14. <result column="first9" jdbcType="INTEGER" property="first9" />
  15. <result column="second0" jdbcType="INTEGER" property="second0" />
  16. <result column="second1" jdbcType="INTEGER" property="second1" />
  17. <result column="second2" jdbcType="INTEGER" property="second2" />
  18. <result column="second3" jdbcType="INTEGER" property="second3" />
  19. <result column="second4" jdbcType="INTEGER" property="second4" />
  20. <result column="second5" jdbcType="INTEGER" property="second5" />
  21. <result column="second6" jdbcType="INTEGER" property="second6" />
  22. <result column="second7" jdbcType="INTEGER" property="second7" />
  23. <result column="second8" jdbcType="INTEGER" property="second8" />
  24. <result column="second9" jdbcType="INTEGER" property="second9" />
  25. <result column="third0" jdbcType="INTEGER" property="third0" />
  26. <result column="third1" jdbcType="INTEGER" property="third1" />
  27. <result column="third2" jdbcType="INTEGER" property="third2" />
  28. <result column="third3" jdbcType="INTEGER" property="third3" />
  29. <result column="third4" jdbcType="INTEGER" property="third4" />
  30. <result column="third5" jdbcType="INTEGER" property="third5" />
  31. <result column="third6" jdbcType="INTEGER" property="third6" />
  32. <result column="third7" jdbcType="INTEGER" property="third7" />
  33. <result column="third8" jdbcType="INTEGER" property="third8" />
  34. <result column="third9" jdbcType="INTEGER" property="third9" />
  35. <result column="fourth0" jdbcType="INTEGER" property="fourth0" />
  36. <result column="fourth1" jdbcType="INTEGER" property="fourth1" />
  37. <result column="fourth2" jdbcType="INTEGER" property="fourth2" />
  38. <result column="fourth3" jdbcType="INTEGER" property="fourth3" />
  39. <result column="fourth4" jdbcType="INTEGER" property="fourth4" />
  40. <result column="fourth5" jdbcType="INTEGER" property="fourth5" />
  41. <result column="fourth6" jdbcType="INTEGER" property="fourth6" />
  42. <result column="fourth7" jdbcType="INTEGER" property="fourth7" />
  43. <result column="fourth8" jdbcType="INTEGER" property="fourth8" />
  44. <result column="fourth9" jdbcType="INTEGER" property="fourth9" />
  45. <result column="fifth0" jdbcType="INTEGER" property="fifth0" />
  46. <result column="fifth1" jdbcType="INTEGER" property="fifth1" />
  47. <result column="fifth2" jdbcType="INTEGER" property="fifth2" />
  48. <result column="fifth3" jdbcType="INTEGER" property="fifth3" />
  49. <result column="fifth4" jdbcType="INTEGER" property="fifth4" />
  50. <result column="fifth5" jdbcType="INTEGER" property="fifth5" />
  51. <result column="fifth6" jdbcType="INTEGER" property="fifth6" />
  52. <result column="fifth7" jdbcType="INTEGER" property="fifth7" />
  53. <result column="fifth8" jdbcType="INTEGER" property="fifth8" />
  54. <result column="fifth9" jdbcType="INTEGER" property="fifth9" />
  55. <result column="sixth0" jdbcType="INTEGER" property="sixth0" />
  56. <result column="sixth1" jdbcType="INTEGER" property="sixth1" />
  57. <result column="sixth2" jdbcType="INTEGER" property="sixth2" />
  58. <result column="sixth3" jdbcType="INTEGER" property="sixth3" />
  59. <result column="sixth4" jdbcType="INTEGER" property="sixth4" />
  60. <result column="sixth5" jdbcType="INTEGER" property="sixth5" />
  61. <result column="sixth6" jdbcType="INTEGER" property="sixth6" />
  62. <result column="sixth7" jdbcType="INTEGER" property="sixth7" />
  63. <result column="sixth8" jdbcType="INTEGER" property="sixth8" />
  64. <result column="sixth9" jdbcType="INTEGER" property="sixth9" />
  65. <result column="seventh0" jdbcType="INTEGER" property="seventh0" />
  66. <result column="seventh1" jdbcType="INTEGER" property="seventh1" />
  67. <result column="seventh2" jdbcType="INTEGER" property="seventh2" />
  68. <result column="seventh3" jdbcType="INTEGER" property="seventh3" />
  69. <result column="seventh4" jdbcType="INTEGER" property="seventh4" />
  70. <result column="seventh5" jdbcType="INTEGER" property="seventh5" />
  71. <result column="seventh6" jdbcType="INTEGER" property="seventh6" />
  72. <result column="seventh7" jdbcType="INTEGER" property="seventh7" />
  73. <result column="seventh8" jdbcType="INTEGER" property="seventh8" />
  74. <result column="seventh9" jdbcType="INTEGER" property="seventh9" />
  75. </resultMap>
  76. <resultMap id="CBResultMap" type="com.e3.zl.wc.bo.CodeBo">
  77. <result column="first0" jdbcType="INTEGER" property="first0" />
  78. <result column="first1" jdbcType="INTEGER" property="first1" />
  79. <result column="first2" jdbcType="INTEGER" property="first2" />
  80. <result column="first3" jdbcType="INTEGER" property="first3" />
  81. <result column="first4" jdbcType="INTEGER" property="first4" />
  82. <result column="first5" jdbcType="INTEGER" property="first5" />
  83. <result column="first6" jdbcType="INTEGER" property="first6" />
  84. <result column="first7" jdbcType="INTEGER" property="first7" />
  85. <result column="first8" jdbcType="INTEGER" property="first8" />
  86. <result column="first9" jdbcType="INTEGER" property="first9" />
  87. <result column="second0" jdbcType="INTEGER" property="second0" />
  88. <result column="second1" jdbcType="INTEGER" property="second1" />
  89. <result column="second2" jdbcType="INTEGER" property="second2" />
  90. <result column="second3" jdbcType="INTEGER" property="second3" />
  91. <result column="second4" jdbcType="INTEGER" property="second4" />
  92. <result column="second5" jdbcType="INTEGER" property="second5" />
  93. <result column="second6" jdbcType="INTEGER" property="second6" />
  94. <result column="second7" jdbcType="INTEGER" property="second7" />
  95. <result column="second8" jdbcType="INTEGER" property="second8" />
  96. <result column="second9" jdbcType="INTEGER" property="second9" />
  97. <result column="third0" jdbcType="INTEGER" property="third0" />
  98. <result column="third1" jdbcType="INTEGER" property="third1" />
  99. <result column="third2" jdbcType="INTEGER" property="third2" />
  100. <result column="third3" jdbcType="INTEGER" property="third3" />
  101. <result column="third4" jdbcType="INTEGER" property="third4" />
  102. <result column="third5" jdbcType="INTEGER" property="third5" />
  103. <result column="third6" jdbcType="INTEGER" property="third6" />
  104. <result column="third7" jdbcType="INTEGER" property="third7" />
  105. <result column="third8" jdbcType="INTEGER" property="third8" />
  106. <result column="third9" jdbcType="INTEGER" property="third9" />
  107. <result column="fourth0" jdbcType="INTEGER" property="fourth0" />
  108. <result column="fourth1" jdbcType="INTEGER" property="fourth1" />
  109. <result column="fourth2" jdbcType="INTEGER" property="fourth2" />
  110. <result column="fourth3" jdbcType="INTEGER" property="fourth3" />
  111. <result column="fourth4" jdbcType="INTEGER" property="fourth4" />
  112. <result column="fourth5" jdbcType="INTEGER" property="fourth5" />
  113. <result column="fourth6" jdbcType="INTEGER" property="fourth6" />
  114. <result column="fourth7" jdbcType="INTEGER" property="fourth7" />
  115. <result column="fourth8" jdbcType="INTEGER" property="fourth8" />
  116. <result column="fourth9" jdbcType="INTEGER" property="fourth9" />
  117. <result column="fifth0" jdbcType="INTEGER" property="fifth0" />
  118. <result column="fifth1" jdbcType="INTEGER" property="fifth1" />
  119. <result column="fifth2" jdbcType="INTEGER" property="fifth2" />
  120. <result column="fifth3" jdbcType="INTEGER" property="fifth3" />
  121. <result column="fifth4" jdbcType="INTEGER" property="fifth4" />
  122. <result column="fifth5" jdbcType="INTEGER" property="fifth5" />
  123. <result column="fifth6" jdbcType="INTEGER" property="fifth6" />
  124. <result column="fifth7" jdbcType="INTEGER" property="fifth7" />
  125. <result column="fifth8" jdbcType="INTEGER" property="fifth8" />
  126. <result column="fifth9" jdbcType="INTEGER" property="fifth9" />
  127. <result column="sixth0" jdbcType="INTEGER" property="sixth0" />
  128. <result column="sixth1" jdbcType="INTEGER" property="sixth1" />
  129. <result column="sixth2" jdbcType="INTEGER" property="sixth2" />
  130. <result column="sixth3" jdbcType="INTEGER" property="sixth3" />
  131. <result column="sixth4" jdbcType="INTEGER" property="sixth4" />
  132. <result column="sixth5" jdbcType="INTEGER" property="sixth5" />
  133. <result column="sixth6" jdbcType="INTEGER" property="sixth6" />
  134. <result column="sixth7" jdbcType="INTEGER" property="sixth7" />
  135. <result column="sixth8" jdbcType="INTEGER" property="sixth8" />
  136. <result column="sixth9" jdbcType="INTEGER" property="sixth9" />
  137. <result column="seventh0" jdbcType="INTEGER" property="seventh0" />
  138. <result column="seventh1" jdbcType="INTEGER" property="seventh1" />
  139. <result column="seventh2" jdbcType="INTEGER" property="seventh2" />
  140. <result column="seventh3" jdbcType="INTEGER" property="seventh3" />
  141. <result column="seventh4" jdbcType="INTEGER" property="seventh4" />
  142. <result column="seventh5" jdbcType="INTEGER" property="seventh5" />
  143. <result column="seventh6" jdbcType="INTEGER" property="seventh6" />
  144. <result column="seventh7" jdbcType="INTEGER" property="seventh7" />
  145. <result column="seventh8" jdbcType="INTEGER" property="seventh8" />
  146. <result column="seventh9" jdbcType="INTEGER" property="seventh9" />
  147. </resultMap>
  148. <resultMap id="CHResultMap" type="com.e3.zl.wc.bo.CodeHiatusBo">
  149. <result column="per_no" jdbcType="INTEGER" property="perNo" />
  150. <result column="per_num" jdbcType="INTEGER" property="perNum" />
  151. <result column="first_code" jdbcType="TINYINT" property="firstCode" />
  152. <result column="second_code" jdbcType="TINYINT" property="secondCode" />
  153. <result column="third_code" jdbcType="TINYINT" property="thirdCode" />
  154. <result column="fourth_code" jdbcType="TINYINT" property="fourthCode" />
  155. <result column="fifth_code" jdbcType="TINYINT" property="fifthCode" />
  156. <result column="fc0" jdbcType="INTEGER" property="fc0" />
  157. <result column="fc1" jdbcType="INTEGER" property="fc1" />
  158. <result column="fc2" jdbcType="INTEGER" property="fc2" />
  159. <result column="fc3" jdbcType="INTEGER" property="fc3" />
  160. <result column="fc4" jdbcType="INTEGER" property="fc4" />
  161. <result column="fc5" jdbcType="INTEGER" property="fc5" />
  162. <result column="fc6" jdbcType="INTEGER" property="fc6" />
  163. <result column="fc7" jdbcType="INTEGER" property="fc7" />
  164. <result column="fc8" jdbcType="INTEGER" property="fc8" />
  165. <result column="fc9" jdbcType="INTEGER" property="fc9" />
  166. <result column="sc0" jdbcType="INTEGER" property="sc0" />
  167. <result column="sc1" jdbcType="INTEGER" property="sc1" />
  168. <result column="sc2" jdbcType="INTEGER" property="sc2" />
  169. <result column="sc3" jdbcType="INTEGER" property="sc3" />
  170. <result column="sc4" jdbcType="INTEGER" property="sc4" />
  171. <result column="sc5" jdbcType="INTEGER" property="sc5" />
  172. <result column="sc6" jdbcType="INTEGER" property="sc6" />
  173. <result column="sc7" jdbcType="INTEGER" property="sc7" />
  174. <result column="sc8" jdbcType="INTEGER" property="sc8" />
  175. <result column="sc9" jdbcType="INTEGER" property="sc9" />
  176. <result column="tc0" jdbcType="INTEGER" property="tc0" />
  177. <result column="tc1" jdbcType="INTEGER" property="tc1" />
  178. <result column="tc2" jdbcType="INTEGER" property="tc2" />
  179. <result column="tc3" jdbcType="INTEGER" property="tc3" />
  180. <result column="tc4" jdbcType="INTEGER" property="tc4" />
  181. <result column="tc5" jdbcType="INTEGER" property="tc5" />
  182. <result column="tc6" jdbcType="INTEGER" property="tc6" />
  183. <result column="tc7" jdbcType="INTEGER" property="tc7" />
  184. <result column="tc8" jdbcType="INTEGER" property="tc8" />
  185. <result column="tc9" jdbcType="INTEGER" property="tc9" />
  186. <result column="fo0" jdbcType="INTEGER" property="fo0" />
  187. <result column="fo1" jdbcType="INTEGER" property="fo1" />
  188. <result column="fo2" jdbcType="INTEGER" property="fo2" />
  189. <result column="fo3" jdbcType="INTEGER" property="fo3" />
  190. <result column="fo4" jdbcType="INTEGER" property="fo4" />
  191. <result column="fo5" jdbcType="INTEGER" property="fo5" />
  192. <result column="fo6" jdbcType="INTEGER" property="fo6" />
  193. <result column="fo7" jdbcType="INTEGER" property="fo7" />
  194. <result column="fo8" jdbcType="INTEGER" property="fo8" />
  195. <result column="fo9" jdbcType="INTEGER" property="fo9" />
  196. <result column="fi0" jdbcType="INTEGER" property="fi0" />
  197. <result column="fi1" jdbcType="INTEGER" property="fi1" />
  198. <result column="fi2" jdbcType="INTEGER" property="fi2" />
  199. <result column="fi3" jdbcType="INTEGER" property="fi3" />
  200. <result column="fi4" jdbcType="INTEGER" property="fi4" />
  201. <result column="fi5" jdbcType="INTEGER" property="fi5" />
  202. <result column="fi6" jdbcType="INTEGER" property="fi6" />
  203. <result column="fi7" jdbcType="INTEGER" property="fi7" />
  204. <result column="fi8" jdbcType="INTEGER" property="fi8" />
  205. <result column="fi9" jdbcType="INTEGER" property="fi9" />
  206. </resultMap>
  207. <select id="queryMaxPerNum" parameterType="java.lang.Integer" resultType="java.lang.Integer">
  208. select MAX(per_num) from seven_star_color;
  209. </select>
  210. <select id="querySevenStarCodeNumByPerNum" parameterType="java.lang.Integer" resultMap="BaseResultMap">
  211. select
  212. SUM(if(t.first_code = 0, 1, 0)) as first0,
  213. SUM(if(t.first_code = 1, 1, 0)) as first1,
  214. SUM(if(t.first_code = 2, 1, 0)) as first2,
  215. SUM(if(t.first_code = 3, 1, 0)) as first3,
  216. SUM(if(t.first_code = 4, 1, 0)) as first4,
  217. SUM(if(t.first_code = 5, 1, 0)) as first5,
  218. SUM(if(t.first_code = 6, 1, 0)) as first6,
  219. SUM(if(t.first_code = 7, 1, 0)) as first7,
  220. SUM(if(t.first_code = 8, 1, 0)) as first8,
  221. SUM(if(t.first_code = 9, 1, 0)) as first9,
  222. SUM(if(t.second_code = 0, 1, 0)) as second0,
  223. SUM(if(t.second_code = 1, 1, 0)) as second1,
  224. SUM(if(t.second_code = 2, 1, 0)) as second2,
  225. SUM(if(t.second_code = 3, 1, 0)) as second3,
  226. SUM(if(t.second_code = 4, 1, 0)) as second4,
  227. SUM(if(t.second_code = 5, 1, 0)) as second5,
  228. SUM(if(t.second_code = 6, 1, 0)) as second6,
  229. SUM(if(t.second_code = 7, 1, 0)) as second7,
  230. SUM(if(t.second_code = 8, 1, 0)) as second8,
  231. SUM(if(t.second_code = 9, 1, 0)) as second9,
  232. SUM(if(t.third_code = 0, 1, 0)) as third0,
  233. SUM(if(t.third_code = 1, 1, 0)) as third1,
  234. SUM(if(t.third_code = 2, 1, 0)) as third2,
  235. SUM(if(t.third_code = 3, 1, 0)) as third3,
  236. SUM(if(t.third_code = 4, 1, 0)) as third4,
  237. SUM(if(t.third_code = 5, 1, 0)) as third5,
  238. SUM(if(t.third_code = 6, 1, 0)) as third6,
  239. SUM(if(t.third_code = 7, 1, 0)) as third7,
  240. SUM(if(t.third_code = 8, 1, 0)) as third8,
  241. SUM(if(t.third_code = 9, 1, 0)) as third9,
  242. SUM(if(t.fourth_code = 0, 1, 0)) as fourth0,
  243. SUM(if(t.fourth_code = 1, 1, 0)) as fourth1,
  244. SUM(if(t.fourth_code = 2, 1, 0)) as fourth2,
  245. SUM(if(t.fourth_code = 3, 1, 0)) as fourth3,
  246. SUM(if(t.fourth_code = 4, 1, 0)) as fourth4,
  247. SUM(if(t.fourth_code = 5, 1, 0)) as fourth5,
  248. SUM(if(t.fourth_code = 6, 1, 0)) as fourth6,
  249. SUM(if(t.fourth_code = 7, 1, 0)) as fourth7,
  250. SUM(if(t.fourth_code = 8, 1, 0)) as fourth8,
  251. SUM(if(t.fourth_code = 9, 1, 0)) as fourth9,
  252. SUM(if(t.fifth_code = 0, 1, 0)) as fifth0,
  253. SUM(if(t.fifth_code = 1, 1, 0)) as fifth1,
  254. SUM(if(t.fifth_code = 2, 1, 0)) as fifth2,
  255. SUM(if(t.fifth_code = 3, 1, 0)) as fifth3,
  256. SUM(if(t.fifth_code = 4, 1, 0)) as fifth4,
  257. SUM(if(t.fifth_code = 5, 1, 0)) as fifth5,
  258. SUM(if(t.fifth_code = 6, 1, 0)) as fifth6,
  259. SUM(if(t.fifth_code = 7, 1, 0)) as fifth7,
  260. SUM(if(t.fifth_code = 8, 1, 0)) as fifth8,
  261. SUM(if(t.fifth_code = 9, 1, 0)) as fifth9,
  262. SUM(if(t.sixth_code = 0, 1, 0)) as sixth0,
  263. SUM(if(t.sixth_code = 1, 1, 0)) as sixth1,
  264. SUM(if(t.sixth_code = 2, 1, 0)) as sixth2,
  265. SUM(if(t.sixth_code = 3, 1, 0)) as sixth3,
  266. SUM(if(t.sixth_code = 4, 1, 0)) as sixth4,
  267. SUM(if(t.sixth_code = 5, 1, 0)) as sixth5,
  268. SUM(if(t.sixth_code = 6, 1, 0)) as sixth6,
  269. SUM(if(t.sixth_code = 7, 1, 0)) as sixth7,
  270. SUM(if(t.sixth_code = 8, 1, 0)) as sixth8,
  271. SUM(if(t.sixth_code = 9, 1, 0)) as sixth9,
  272. SUM(if(t.seventh_code = 0, 1, 0)) as seventh0,
  273. SUM(if(t.seventh_code = 1, 1, 0)) as seventh1,
  274. SUM(if(t.seventh_code = 2, 1, 0)) as seventh2,
  275. SUM(if(t.seventh_code = 3, 1, 0)) as seventh3,
  276. SUM(if(t.seventh_code = 4, 1, 0)) as seventh4,
  277. SUM(if(t.seventh_code = 5, 1, 0)) as seventh5,
  278. SUM(if(t.seventh_code = 6, 1, 0)) as seventh6,
  279. SUM(if(t.seventh_code = 7, 1, 0)) as seventh7,
  280. SUM(if(t.seventh_code = 8, 1, 0)) as seventh8,
  281. SUM(if(t.seventh_code = 9, 1, 0)) as seventh9
  282. from seven_star_color t where EXISTS (
  283. select 1 from seven_star_color c
  284. join seven_star_color l on l.first_code = c.first_code
  285. where c.per_num = #{perNum,jdbcType=INTEGER} and l.per_num &lt; c.per_num and l.per_num + 1 = t.per_num
  286. )
  287. UNION
  288. select
  289. SUM(if(t.first_code = 0, 1, 0)) as first0,
  290. SUM(if(t.first_code = 1, 1, 0)) as first1,
  291. SUM(if(t.first_code = 2, 1, 0)) as first2,
  292. SUM(if(t.first_code = 3, 1, 0)) as first3,
  293. SUM(if(t.first_code = 4, 1, 0)) as first4,
  294. SUM(if(t.first_code = 5, 1, 0)) as first5,
  295. SUM(if(t.first_code = 6, 1, 0)) as first6,
  296. SUM(if(t.first_code = 7, 1, 0)) as first7,
  297. SUM(if(t.first_code = 8, 1, 0)) as first8,
  298. SUM(if(t.first_code = 9, 1, 0)) as first9,
  299. SUM(if(t.second_code = 0, 1, 0)) as second0,
  300. SUM(if(t.second_code = 1, 1, 0)) as second1,
  301. SUM(if(t.second_code = 2, 1, 0)) as second2,
  302. SUM(if(t.second_code = 3, 1, 0)) as second3,
  303. SUM(if(t.second_code = 4, 1, 0)) as second4,
  304. SUM(if(t.second_code = 5, 1, 0)) as second5,
  305. SUM(if(t.second_code = 6, 1, 0)) as second6,
  306. SUM(if(t.second_code = 7, 1, 0)) as second7,
  307. SUM(if(t.second_code = 8, 1, 0)) as second8,
  308. SUM(if(t.second_code = 9, 1, 0)) as second9,
  309. SUM(if(t.third_code = 0, 1, 0)) as third0,
  310. SUM(if(t.third_code = 1, 1, 0)) as third1,
  311. SUM(if(t.third_code = 2, 1, 0)) as third2,
  312. SUM(if(t.third_code = 3, 1, 0)) as third3,
  313. SUM(if(t.third_code = 4, 1, 0)) as third4,
  314. SUM(if(t.third_code = 5, 1, 0)) as third5,
  315. SUM(if(t.third_code = 6, 1, 0)) as third6,
  316. SUM(if(t.third_code = 7, 1, 0)) as third7,
  317. SUM(if(t.third_code = 8, 1, 0)) as third8,
  318. SUM(if(t.third_code = 9, 1, 0)) as third9,
  319. SUM(if(t.fourth_code = 0, 1, 0)) as fourth0,
  320. SUM(if(t.fourth_code = 1, 1, 0)) as fourth1,
  321. SUM(if(t.fourth_code = 2, 1, 0)) as fourth2,
  322. SUM(if(t.fourth_code = 3, 1, 0)) as fourth3,
  323. SUM(if(t.fourth_code = 4, 1, 0)) as fourth4,
  324. SUM(if(t.fourth_code = 5, 1, 0)) as fourth5,
  325. SUM(if(t.fourth_code = 6, 1, 0)) as fourth6,
  326. SUM(if(t.fourth_code = 7, 1, 0)) as fourth7,
  327. SUM(if(t.fourth_code = 8, 1, 0)) as fourth8,
  328. SUM(if(t.fourth_code = 9, 1, 0)) as fourth9,
  329. SUM(if(t.fifth_code = 0, 1, 0)) as fifth0,
  330. SUM(if(t.fifth_code = 1, 1, 0)) as fifth1,
  331. SUM(if(t.fifth_code = 2, 1, 0)) as fifth2,
  332. SUM(if(t.fifth_code = 3, 1, 0)) as fifth3,
  333. SUM(if(t.fifth_code = 4, 1, 0)) as fifth4,
  334. SUM(if(t.fifth_code = 5, 1, 0)) as fifth5,
  335. SUM(if(t.fifth_code = 6, 1, 0)) as fifth6,
  336. SUM(if(t.fifth_code = 7, 1, 0)) as fifth7,
  337. SUM(if(t.fifth_code = 8, 1, 0)) as fifth8,
  338. SUM(if(t.fifth_code = 9, 1, 0)) as fifth9,
  339. SUM(if(t.sixth_code = 0, 1, 0)) as sixth0,
  340. SUM(if(t.sixth_code = 1, 1, 0)) as sixth1,
  341. SUM(if(t.sixth_code = 2, 1, 0)) as sixth2,
  342. SUM(if(t.sixth_code = 3, 1, 0)) as sixth3,
  343. SUM(if(t.sixth_code = 4, 1, 0)) as sixth4,
  344. SUM(if(t.sixth_code = 5, 1, 0)) as sixth5,
  345. SUM(if(t.sixth_code = 6, 1, 0)) as sixth6,
  346. SUM(if(t.sixth_code = 7, 1, 0)) as sixth7,
  347. SUM(if(t.sixth_code = 8, 1, 0)) as sixth8,
  348. SUM(if(t.sixth_code = 9, 1, 0)) as sixth9,
  349. SUM(if(t.seventh_code = 0, 1, 0)) as seventh0,
  350. SUM(if(t.seventh_code = 1, 1, 0)) as seventh1,
  351. SUM(if(t.seventh_code = 2, 1, 0)) as seventh2,
  352. SUM(if(t.seventh_code = 3, 1, 0)) as seventh3,
  353. SUM(if(t.seventh_code = 4, 1, 0)) as seventh4,
  354. SUM(if(t.seventh_code = 5, 1, 0)) as seventh5,
  355. SUM(if(t.seventh_code = 6, 1, 0)) as seventh6,
  356. SUM(if(t.seventh_code = 7, 1, 0)) as seventh7,
  357. SUM(if(t.seventh_code = 8, 1, 0)) as seventh8,
  358. SUM(if(t.seventh_code = 9, 1, 0)) as seventh9
  359. from seven_star_color t where EXISTS (
  360. select 1 from seven_star_color c
  361. join seven_star_color l on l.second_code = c.second_code
  362. where c.per_num = #{perNum,jdbcType=INTEGER} and l.per_num &lt; c.per_num and l.per_num + 1 = t.per_num
  363. )
  364. UNION
  365. select
  366. SUM(if(t.first_code = 0, 1, 0)) as first0,
  367. SUM(if(t.first_code = 1, 1, 0)) as first1,
  368. SUM(if(t.first_code = 2, 1, 0)) as first2,
  369. SUM(if(t.first_code = 3, 1, 0)) as first3,
  370. SUM(if(t.first_code = 4, 1, 0)) as first4,
  371. SUM(if(t.first_code = 5, 1, 0)) as first5,
  372. SUM(if(t.first_code = 6, 1, 0)) as first6,
  373. SUM(if(t.first_code = 7, 1, 0)) as first7,
  374. SUM(if(t.first_code = 8, 1, 0)) as first8,
  375. SUM(if(t.first_code = 9, 1, 0)) as first9,
  376. SUM(if(t.second_code = 0, 1, 0)) as second0,
  377. SUM(if(t.second_code = 1, 1, 0)) as second1,
  378. SUM(if(t.second_code = 2, 1, 0)) as second2,
  379. SUM(if(t.second_code = 3, 1, 0)) as second3,
  380. SUM(if(t.second_code = 4, 1, 0)) as second4,
  381. SUM(if(t.second_code = 5, 1, 0)) as second5,
  382. SUM(if(t.second_code = 6, 1, 0)) as second6,
  383. SUM(if(t.second_code = 7, 1, 0)) as second7,
  384. SUM(if(t.second_code = 8, 1, 0)) as second8,
  385. SUM(if(t.second_code = 9, 1, 0)) as second9,
  386. SUM(if(t.third_code = 0, 1, 0)) as third0,
  387. SUM(if(t.third_code = 1, 1, 0)) as third1,
  388. SUM(if(t.third_code = 2, 1, 0)) as third2,
  389. SUM(if(t.third_code = 3, 1, 0)) as third3,
  390. SUM(if(t.third_code = 4, 1, 0)) as third4,
  391. SUM(if(t.third_code = 5, 1, 0)) as third5,
  392. SUM(if(t.third_code = 6, 1, 0)) as third6,
  393. SUM(if(t.third_code = 7, 1, 0)) as third7,
  394. SUM(if(t.third_code = 8, 1, 0)) as third8,
  395. SUM(if(t.third_code = 9, 1, 0)) as third9,
  396. SUM(if(t.fourth_code = 0, 1, 0)) as fourth0,
  397. SUM(if(t.fourth_code = 1, 1, 0)) as fourth1,
  398. SUM(if(t.fourth_code = 2, 1, 0)) as fourth2,
  399. SUM(if(t.fourth_code = 3, 1, 0)) as fourth3,
  400. SUM(if(t.fourth_code = 4, 1, 0)) as fourth4,
  401. SUM(if(t.fourth_code = 5, 1, 0)) as fourth5,
  402. SUM(if(t.fourth_code = 6, 1, 0)) as fourth6,
  403. SUM(if(t.fourth_code = 7, 1, 0)) as fourth7,
  404. SUM(if(t.fourth_code = 8, 1, 0)) as fourth8,
  405. SUM(if(t.fourth_code = 9, 1, 0)) as fourth9,
  406. SUM(if(t.fifth_code = 0, 1, 0)) as fifth0,
  407. SUM(if(t.fifth_code = 1, 1, 0)) as fifth1,
  408. SUM(if(t.fifth_code = 2, 1, 0)) as fifth2,
  409. SUM(if(t.fifth_code = 3, 1, 0)) as fifth3,
  410. SUM(if(t.fifth_code = 4, 1, 0)) as fifth4,
  411. SUM(if(t.fifth_code = 5, 1, 0)) as fifth5,
  412. SUM(if(t.fifth_code = 6, 1, 0)) as fifth6,
  413. SUM(if(t.fifth_code = 7, 1, 0)) as fifth7,
  414. SUM(if(t.fifth_code = 8, 1, 0)) as fifth8,
  415. SUM(if(t.fifth_code = 9, 1, 0)) as fifth9,
  416. SUM(if(t.sixth_code = 0, 1, 0)) as sixth0,
  417. SUM(if(t.sixth_code = 1, 1, 0)) as sixth1,
  418. SUM(if(t.sixth_code = 2, 1, 0)) as sixth2,
  419. SUM(if(t.sixth_code = 3, 1, 0)) as sixth3,
  420. SUM(if(t.sixth_code = 4, 1, 0)) as sixth4,
  421. SUM(if(t.sixth_code = 5, 1, 0)) as sixth5,
  422. SUM(if(t.sixth_code = 6, 1, 0)) as sixth6,
  423. SUM(if(t.sixth_code = 7, 1, 0)) as sixth7,
  424. SUM(if(t.sixth_code = 8, 1, 0)) as sixth8,
  425. SUM(if(t.sixth_code = 9, 1, 0)) as sixth9,
  426. SUM(if(t.seventh_code = 0, 1, 0)) as seventh0,
  427. SUM(if(t.seventh_code = 1, 1, 0)) as seventh1,
  428. SUM(if(t.seventh_code = 2, 1, 0)) as seventh2,
  429. SUM(if(t.seventh_code = 3, 1, 0)) as seventh3,
  430. SUM(if(t.seventh_code = 4, 1, 0)) as seventh4,
  431. SUM(if(t.seventh_code = 5, 1, 0)) as seventh5,
  432. SUM(if(t.seventh_code = 6, 1, 0)) as seventh6,
  433. SUM(if(t.seventh_code = 7, 1, 0)) as seventh7,
  434. SUM(if(t.seventh_code = 8, 1, 0)) as seventh8,
  435. SUM(if(t.seventh_code = 9, 1, 0)) as seventh9
  436. from seven_star_color t where EXISTS (
  437. select 1 from seven_star_color c
  438. join seven_star_color l on l.third_code = c.third_code
  439. where c.per_num = #{perNum,jdbcType=INTEGER} and l.per_num &lt; c.per_num and l.per_num + 1 = t.per_num
  440. )
  441. UNION
  442. select
  443. SUM(if(t.first_code = 0, 1, 0)) as first0,
  444. SUM(if(t.first_code = 1, 1, 0)) as first1,
  445. SUM(if(t.first_code = 2, 1, 0)) as first2,
  446. SUM(if(t.first_code = 3, 1, 0)) as first3,
  447. SUM(if(t.first_code = 4, 1, 0)) as first4,
  448. SUM(if(t.first_code = 5, 1, 0)) as first5,
  449. SUM(if(t.first_code = 6, 1, 0)) as first6,
  450. SUM(if(t.first_code = 7, 1, 0)) as first7,
  451. SUM(if(t.first_code = 8, 1, 0)) as first8,
  452. SUM(if(t.first_code = 9, 1, 0)) as first9,
  453. SUM(if(t.second_code = 0, 1, 0)) as second0,
  454. SUM(if(t.second_code = 1, 1, 0)) as second1,
  455. SUM(if(t.second_code = 2, 1, 0)) as second2,
  456. SUM(if(t.second_code = 3, 1, 0)) as second3,
  457. SUM(if(t.second_code = 4, 1, 0)) as second4,
  458. SUM(if(t.second_code = 5, 1, 0)) as second5,
  459. SUM(if(t.second_code = 6, 1, 0)) as second6,
  460. SUM(if(t.second_code = 7, 1, 0)) as second7,
  461. SUM(if(t.second_code = 8, 1, 0)) as second8,
  462. SUM(if(t.second_code = 9, 1, 0)) as second9,
  463. SUM(if(t.third_code = 0, 1, 0)) as third0,
  464. SUM(if(t.third_code = 1, 1, 0)) as third1,
  465. SUM(if(t.third_code = 2, 1, 0)) as third2,
  466. SUM(if(t.third_code = 3, 1, 0)) as third3,
  467. SUM(if(t.third_code = 4, 1, 0)) as third4,
  468. SUM(if(t.third_code = 5, 1, 0)) as third5,
  469. SUM(if(t.third_code = 6, 1, 0)) as third6,
  470. SUM(if(t.third_code = 7, 1, 0)) as third7,
  471. SUM(if(t.third_code = 8, 1, 0)) as third8,
  472. SUM(if(t.third_code = 9, 1, 0)) as third9,
  473. SUM(if(t.fourth_code = 0, 1, 0)) as fourth0,
  474. SUM(if(t.fourth_code = 1, 1, 0)) as fourth1,
  475. SUM(if(t.fourth_code = 2, 1, 0)) as fourth2,
  476. SUM(if(t.fourth_code = 3, 1, 0)) as fourth3,
  477. SUM(if(t.fourth_code = 4, 1, 0)) as fourth4,
  478. SUM(if(t.fourth_code = 5, 1, 0)) as fourth5,
  479. SUM(if(t.fourth_code = 6, 1, 0)) as fourth6,
  480. SUM(if(t.fourth_code = 7, 1, 0)) as fourth7,
  481. SUM(if(t.fourth_code = 8, 1, 0)) as fourth8,
  482. SUM(if(t.fourth_code = 9, 1, 0)) as fourth9,
  483. SUM(if(t.fifth_code = 0, 1, 0)) as fifth0,
  484. SUM(if(t.fifth_code = 1, 1, 0)) as fifth1,
  485. SUM(if(t.fifth_code = 2, 1, 0)) as fifth2,
  486. SUM(if(t.fifth_code = 3, 1, 0)) as fifth3,
  487. SUM(if(t.fifth_code = 4, 1, 0)) as fifth4,
  488. SUM(if(t.fifth_code = 5, 1, 0)) as fifth5,
  489. SUM(if(t.fifth_code = 6, 1, 0)) as fifth6,
  490. SUM(if(t.fifth_code = 7, 1, 0)) as fifth7,
  491. SUM(if(t.fifth_code = 8, 1, 0)) as fifth8,
  492. SUM(if(t.fifth_code = 9, 1, 0)) as fifth9,
  493. SUM(if(t.sixth_code = 0, 1, 0)) as sixth0,
  494. SUM(if(t.sixth_code = 1, 1, 0)) as sixth1,
  495. SUM(if(t.sixth_code = 2, 1, 0)) as sixth2,
  496. SUM(if(t.sixth_code = 3, 1, 0)) as sixth3,
  497. SUM(if(t.sixth_code = 4, 1, 0)) as sixth4,
  498. SUM(if(t.sixth_code = 5, 1, 0)) as sixth5,
  499. SUM(if(t.sixth_code = 6, 1, 0)) as sixth6,
  500. SUM(if(t.sixth_code = 7, 1, 0)) as sixth7,
  501. SUM(if(t.sixth_code = 8, 1, 0)) as sixth8,
  502. SUM(if(t.sixth_code = 9, 1, 0)) as sixth9,
  503. SUM(if(t.seventh_code = 0, 1, 0)) as seventh0,
  504. SUM(if(t.seventh_code = 1, 1, 0)) as seventh1,
  505. SUM(if(t.seventh_code = 2, 1, 0)) as seventh2,
  506. SUM(if(t.seventh_code = 3, 1, 0)) as seventh3,
  507. SUM(if(t.seventh_code = 4, 1, 0)) as seventh4,
  508. SUM(if(t.seventh_code = 5, 1, 0)) as seventh5,
  509. SUM(if(t.seventh_code = 6, 1, 0)) as seventh6,
  510. SUM(if(t.seventh_code = 7, 1, 0)) as seventh7,
  511. SUM(if(t.seventh_code = 8, 1, 0)) as seventh8,
  512. SUM(if(t.seventh_code = 9, 1, 0)) as seventh9
  513. from seven_star_color t where EXISTS (
  514. select 1 from seven_star_color c
  515. join seven_star_color l on l.fourth_code = c.fourth_code
  516. where c.per_num = #{perNum,jdbcType=INTEGER} and l.per_num &lt; c.per_num and l.per_num + 1 = t.per_num
  517. )
  518. UNION
  519. select
  520. SUM(if(t.first_code = 0, 1, 0)) as first0,
  521. SUM(if(t.first_code = 1, 1, 0)) as first1,
  522. SUM(if(t.first_code = 2, 1, 0)) as first2,
  523. SUM(if(t.first_code = 3, 1, 0)) as first3,
  524. SUM(if(t.first_code = 4, 1, 0)) as first4,
  525. SUM(if(t.first_code = 5, 1, 0)) as first5,
  526. SUM(if(t.first_code = 6, 1, 0)) as first6,
  527. SUM(if(t.first_code = 7, 1, 0)) as first7,
  528. SUM(if(t.first_code = 8, 1, 0)) as first8,
  529. SUM(if(t.first_code = 9, 1, 0)) as first9,
  530. SUM(if(t.second_code = 0, 1, 0)) as second0,
  531. SUM(if(t.second_code = 1, 1, 0)) as second1,
  532. SUM(if(t.second_code = 2, 1, 0)) as second2,
  533. SUM(if(t.second_code = 3, 1, 0)) as second3,
  534. SUM(if(t.second_code = 4, 1, 0)) as second4,
  535. SUM(if(t.second_code = 5, 1, 0)) as second5,
  536. SUM(if(t.second_code = 6, 1, 0)) as second6,
  537. SUM(if(t.second_code = 7, 1, 0)) as second7,
  538. SUM(if(t.second_code = 8, 1, 0)) as second8,
  539. SUM(if(t.second_code = 9, 1, 0)) as second9,
  540. SUM(if(t.third_code = 0, 1, 0)) as third0,
  541. SUM(if(t.third_code = 1, 1, 0)) as third1,
  542. SUM(if(t.third_code = 2, 1, 0)) as third2,
  543. SUM(if(t.third_code = 3, 1, 0)) as third3,
  544. SUM(if(t.third_code = 4, 1, 0)) as third4,
  545. SUM(if(t.third_code = 5, 1, 0)) as third5,
  546. SUM(if(t.third_code = 6, 1, 0)) as third6,
  547. SUM(if(t.third_code = 7, 1, 0)) as third7,
  548. SUM(if(t.third_code = 8, 1, 0)) as third8,
  549. SUM(if(t.third_code = 9, 1, 0)) as third9,
  550. SUM(if(t.fourth_code = 0, 1, 0)) as fourth0,
  551. SUM(if(t.fourth_code = 1, 1, 0)) as fourth1,
  552. SUM(if(t.fourth_code = 2, 1, 0)) as fourth2,
  553. SUM(if(t.fourth_code = 3, 1, 0)) as fourth3,
  554. SUM(if(t.fourth_code = 4, 1, 0)) as fourth4,
  555. SUM(if(t.fourth_code = 5, 1, 0)) as fourth5,
  556. SUM(if(t.fourth_code = 6, 1, 0)) as fourth6,
  557. SUM(if(t.fourth_code = 7, 1, 0)) as fourth7,
  558. SUM(if(t.fourth_code = 8, 1, 0)) as fourth8,
  559. SUM(if(t.fourth_code = 9, 1, 0)) as fourth9,
  560. SUM(if(t.fifth_code = 0, 1, 0)) as fifth0,
  561. SUM(if(t.fifth_code = 1, 1, 0)) as fifth1,
  562. SUM(if(t.fifth_code = 2, 1, 0)) as fifth2,
  563. SUM(if(t.fifth_code = 3, 1, 0)) as fifth3,
  564. SUM(if(t.fifth_code = 4, 1, 0)) as fifth4,
  565. SUM(if(t.fifth_code = 5, 1, 0)) as fifth5,
  566. SUM(if(t.fifth_code = 6, 1, 0)) as fifth6,
  567. SUM(if(t.fifth_code = 7, 1, 0)) as fifth7,
  568. SUM(if(t.fifth_code = 8, 1, 0)) as fifth8,
  569. SUM(if(t.fifth_code = 9, 1, 0)) as fifth9,
  570. SUM(if(t.sixth_code = 0, 1, 0)) as sixth0,
  571. SUM(if(t.sixth_code = 1, 1, 0)) as sixth1,
  572. SUM(if(t.sixth_code = 2, 1, 0)) as sixth2,
  573. SUM(if(t.sixth_code = 3, 1, 0)) as sixth3,
  574. SUM(if(t.sixth_code = 4, 1, 0)) as sixth4,
  575. SUM(if(t.sixth_code = 5, 1, 0)) as sixth5,
  576. SUM(if(t.sixth_code = 6, 1, 0)) as sixth6,
  577. SUM(if(t.sixth_code = 7, 1, 0)) as sixth7,
  578. SUM(if(t.sixth_code = 8, 1, 0)) as sixth8,
  579. SUM(if(t.sixth_code = 9, 1, 0)) as sixth9,
  580. SUM(if(t.seventh_code = 0, 1, 0)) as seventh0,
  581. SUM(if(t.seventh_code = 1, 1, 0)) as seventh1,
  582. SUM(if(t.seventh_code = 2, 1, 0)) as seventh2,
  583. SUM(if(t.seventh_code = 3, 1, 0)) as seventh3,
  584. SUM(if(t.seventh_code = 4, 1, 0)) as seventh4,
  585. SUM(if(t.seventh_code = 5, 1, 0)) as seventh5,
  586. SUM(if(t.seventh_code = 6, 1, 0)) as seventh6,
  587. SUM(if(t.seventh_code = 7, 1, 0)) as seventh7,
  588. SUM(if(t.seventh_code = 8, 1, 0)) as seventh8,
  589. SUM(if(t.seventh_code = 9, 1, 0)) as seventh9
  590. from seven_star_color t where EXISTS (
  591. select 1 from seven_star_color c
  592. join seven_star_color l on l.fifth_code = c.fifth_code
  593. where c.per_num = #{perNum,jdbcType=INTEGER} and l.per_num &lt; c.per_num and l.per_num + 1 = t.per_num
  594. )
  595. UNION
  596. select
  597. SUM(if(t.first_code = 0, 1, 0)) as first0,
  598. SUM(if(t.first_code = 1, 1, 0)) as first1,
  599. SUM(if(t.first_code = 2, 1, 0)) as first2,
  600. SUM(if(t.first_code = 3, 1, 0)) as first3,
  601. SUM(if(t.first_code = 4, 1, 0)) as first4,
  602. SUM(if(t.first_code = 5, 1, 0)) as first5,
  603. SUM(if(t.first_code = 6, 1, 0)) as first6,
  604. SUM(if(t.first_code = 7, 1, 0)) as first7,
  605. SUM(if(t.first_code = 8, 1, 0)) as first8,
  606. SUM(if(t.first_code = 9, 1, 0)) as first9,
  607. SUM(if(t.second_code = 0, 1, 0)) as second0,
  608. SUM(if(t.second_code = 1, 1, 0)) as second1,
  609. SUM(if(t.second_code = 2, 1, 0)) as second2,
  610. SUM(if(t.second_code = 3, 1, 0)) as second3,
  611. SUM(if(t.second_code = 4, 1, 0)) as second4,
  612. SUM(if(t.second_code = 5, 1, 0)) as second5,
  613. SUM(if(t.second_code = 6, 1, 0)) as second6,
  614. SUM(if(t.second_code = 7, 1, 0)) as second7,
  615. SUM(if(t.second_code = 8, 1, 0)) as second8,
  616. SUM(if(t.second_code = 9, 1, 0)) as second9,
  617. SUM(if(t.third_code = 0, 1, 0)) as third0,
  618. SUM(if(t.third_code = 1, 1, 0)) as third1,
  619. SUM(if(t.third_code = 2, 1, 0)) as third2,
  620. SUM(if(t.third_code = 3, 1, 0)) as third3,
  621. SUM(if(t.third_code = 4, 1, 0)) as third4,
  622. SUM(if(t.third_code = 5, 1, 0)) as third5,
  623. SUM(if(t.third_code = 6, 1, 0)) as third6,
  624. SUM(if(t.third_code = 7, 1, 0)) as third7,
  625. SUM(if(t.third_code = 8, 1, 0)) as third8,
  626. SUM(if(t.third_code = 9, 1, 0)) as third9,
  627. SUM(if(t.fourth_code = 0, 1, 0)) as fourth0,
  628. SUM(if(t.fourth_code = 1, 1, 0)) as fourth1,
  629. SUM(if(t.fourth_code = 2, 1, 0)) as fourth2,
  630. SUM(if(t.fourth_code = 3, 1, 0)) as fourth3,
  631. SUM(if(t.fourth_code = 4, 1, 0)) as fourth4,
  632. SUM(if(t.fourth_code = 5, 1, 0)) as fourth5,
  633. SUM(if(t.fourth_code = 6, 1, 0)) as fourth6,
  634. SUM(if(t.fourth_code = 7, 1, 0)) as fourth7,
  635. SUM(if(t.fourth_code = 8, 1, 0)) as fourth8,
  636. SUM(if(t.fourth_code = 9, 1, 0)) as fourth9,
  637. SUM(if(t.fifth_code = 0, 1, 0)) as fifth0,
  638. SUM(if(t.fifth_code = 1, 1, 0)) as fifth1,
  639. SUM(if(t.fifth_code = 2, 1, 0)) as fifth2,
  640. SUM(if(t.fifth_code = 3, 1, 0)) as fifth3,
  641. SUM(if(t.fifth_code = 4, 1, 0)) as fifth4,
  642. SUM(if(t.fifth_code = 5, 1, 0)) as fifth5,
  643. SUM(if(t.fifth_code = 6, 1, 0)) as fifth6,
  644. SUM(if(t.fifth_code = 7, 1, 0)) as fifth7,
  645. SUM(if(t.fifth_code = 8, 1, 0)) as fifth8,
  646. SUM(if(t.fifth_code = 9, 1, 0)) as fifth9,
  647. SUM(if(t.sixth_code = 0, 1, 0)) as sixth0,
  648. SUM(if(t.sixth_code = 1, 1, 0)) as sixth1,
  649. SUM(if(t.sixth_code = 2, 1, 0)) as sixth2,
  650. SUM(if(t.sixth_code = 3, 1, 0)) as sixth3,
  651. SUM(if(t.sixth_code = 4, 1, 0)) as sixth4,
  652. SUM(if(t.sixth_code = 5, 1, 0)) as sixth5,
  653. SUM(if(t.sixth_code = 6, 1, 0)) as sixth6,
  654. SUM(if(t.sixth_code = 7, 1, 0)) as sixth7,
  655. SUM(if(t.sixth_code = 8, 1, 0)) as sixth8,
  656. SUM(if(t.sixth_code = 9, 1, 0)) as sixth9,
  657. SUM(if(t.seventh_code = 0, 1, 0)) as seventh0,
  658. SUM(if(t.seventh_code = 1, 1, 0)) as seventh1,
  659. SUM(if(t.seventh_code = 2, 1, 0)) as seventh2,
  660. SUM(if(t.seventh_code = 3, 1, 0)) as seventh3,
  661. SUM(if(t.seventh_code = 4, 1, 0)) as seventh4,
  662. SUM(if(t.seventh_code = 5, 1, 0)) as seventh5,
  663. SUM(if(t.seventh_code = 6, 1, 0)) as seventh6,
  664. SUM(if(t.seventh_code = 7, 1, 0)) as seventh7,
  665. SUM(if(t.seventh_code = 8, 1, 0)) as seventh8,
  666. SUM(if(t.seventh_code = 9, 1, 0)) as seventh9
  667. from seven_star_color t where EXISTS (
  668. select 1 from seven_star_color c
  669. join seven_star_color l on l.sixth_code = c.sixth_code
  670. where c.per_num = #{perNum,jdbcType=INTEGER} and l.per_num &lt; c.per_num and l.per_num + 1 = t.per_num
  671. )
  672. UNION
  673. select
  674. SUM(if(t.first_code = 0, 1, 0)) as first0,
  675. SUM(if(t.first_code = 1, 1, 0)) as first1,
  676. SUM(if(t.first_code = 2, 1, 0)) as first2,
  677. SUM(if(t.first_code = 3, 1, 0)) as first3,
  678. SUM(if(t.first_code = 4, 1, 0)) as first4,
  679. SUM(if(t.first_code = 5, 1, 0)) as first5,
  680. SUM(if(t.first_code = 6, 1, 0)) as first6,
  681. SUM(if(t.first_code = 7, 1, 0)) as first7,
  682. SUM(if(t.first_code = 8, 1, 0)) as first8,
  683. SUM(if(t.first_code = 9, 1, 0)) as first9,
  684. SUM(if(t.second_code = 0, 1, 0)) as second0,
  685. SUM(if(t.second_code = 1, 1, 0)) as second1,
  686. SUM(if(t.second_code = 2, 1, 0)) as second2,
  687. SUM(if(t.second_code = 3, 1, 0)) as second3,
  688. SUM(if(t.second_code = 4, 1, 0)) as second4,
  689. SUM(if(t.second_code = 5, 1, 0)) as second5,
  690. SUM(if(t.second_code = 6, 1, 0)) as second6,
  691. SUM(if(t.second_code = 7, 1, 0)) as second7,
  692. SUM(if(t.second_code = 8, 1, 0)) as second8,
  693. SUM(if(t.second_code = 9, 1, 0)) as second9,
  694. SUM(if(t.third_code = 0, 1, 0)) as third0,
  695. SUM(if(t.third_code = 1, 1, 0)) as third1,
  696. SUM(if(t.third_code = 2, 1, 0)) as third2,
  697. SUM(if(t.third_code = 3, 1, 0)) as third3,
  698. SUM(if(t.third_code = 4, 1, 0)) as third4,
  699. SUM(if(t.third_code = 5, 1, 0)) as third5,
  700. SUM(if(t.third_code = 6, 1, 0)) as third6,
  701. SUM(if(t.third_code = 7, 1, 0)) as third7,
  702. SUM(if(t.third_code = 8, 1, 0)) as third8,
  703. SUM(if(t.third_code = 9, 1, 0)) as third9,
  704. SUM(if(t.fourth_code = 0, 1, 0)) as fourth0,
  705. SUM(if(t.fourth_code = 1, 1, 0)) as fourth1,
  706. SUM(if(t.fourth_code = 2, 1, 0)) as fourth2,
  707. SUM(if(t.fourth_code = 3, 1, 0)) as fourth3,
  708. SUM(if(t.fourth_code = 4, 1, 0)) as fourth4,
  709. SUM(if(t.fourth_code = 5, 1, 0)) as fourth5,
  710. SUM(if(t.fourth_code = 6, 1, 0)) as fourth6,
  711. SUM(if(t.fourth_code = 7, 1, 0)) as fourth7,
  712. SUM(if(t.fourth_code = 8, 1, 0)) as fourth8,
  713. SUM(if(t.fourth_code = 9, 1, 0)) as fourth9,
  714. SUM(if(t.fifth_code = 0, 1, 0)) as fifth0,
  715. SUM(if(t.fifth_code = 1, 1, 0)) as fifth1,
  716. SUM(if(t.fifth_code = 2, 1, 0)) as fifth2,
  717. SUM(if(t.fifth_code = 3, 1, 0)) as fifth3,
  718. SUM(if(t.fifth_code = 4, 1, 0)) as fifth4,
  719. SUM(if(t.fifth_code = 5, 1, 0)) as fifth5,
  720. SUM(if(t.fifth_code = 6, 1, 0)) as fifth6,
  721. SUM(if(t.fifth_code = 7, 1, 0)) as fifth7,
  722. SUM(if(t.fifth_code = 8, 1, 0)) as fifth8,
  723. SUM(if(t.fifth_code = 9, 1, 0)) as fifth9,
  724. SUM(if(t.sixth_code = 0, 1, 0)) as sixth0,
  725. SUM(if(t.sixth_code = 1, 1, 0)) as sixth1,
  726. SUM(if(t.sixth_code = 2, 1, 0)) as sixth2,
  727. SUM(if(t.sixth_code = 3, 1, 0)) as sixth3,
  728. SUM(if(t.sixth_code = 4, 1, 0)) as sixth4,
  729. SUM(if(t.sixth_code = 5, 1, 0)) as sixth5,
  730. SUM(if(t.sixth_code = 6, 1, 0)) as sixth6,
  731. SUM(if(t.sixth_code = 7, 1, 0)) as sixth7,
  732. SUM(if(t.sixth_code = 8, 1, 0)) as sixth8,
  733. SUM(if(t.sixth_code = 9, 1, 0)) as sixth9,
  734. SUM(if(t.seventh_code = 0, 1, 0)) as seventh0,
  735. SUM(if(t.seventh_code = 1, 1, 0)) as seventh1,
  736. SUM(if(t.seventh_code = 2, 1, 0)) as seventh2,
  737. SUM(if(t.seventh_code = 3, 1, 0)) as seventh3,
  738. SUM(if(t.seventh_code = 4, 1, 0)) as seventh4,
  739. SUM(if(t.seventh_code = 5, 1, 0)) as seventh5,
  740. SUM(if(t.seventh_code = 6, 1, 0)) as seventh6,
  741. SUM(if(t.seventh_code = 7, 1, 0)) as seventh7,
  742. SUM(if(t.seventh_code = 8, 1, 0)) as seventh8,
  743. SUM(if(t.seventh_code = 9, 1, 0)) as seventh9
  744. from seven_star_color t where EXISTS (
  745. select 1 from seven_star_color c
  746. join seven_star_color l on l.seventh_code = c.seventh_code
  747. where c.per_num = #{perNum,jdbcType=INTEGER} and l.per_num &lt; c.per_num and l.per_num + 1 = t.per_num
  748. );
  749. </select>
  750. <select id="queryRankFiveCodeNumByPerNum" parameterType="com.e3.zl.wc.model.RankFive" resultMap="CBResultMap">
  751. select
  752. SUM(if(t.first_code = 0, 1, 0)) as first0,
  753. SUM(if(t.first_code = 1, 1, 0)) as first1,
  754. SUM(if(t.first_code = 2, 1, 0)) as first2,
  755. SUM(if(t.first_code = 3, 1, 0)) as first3,
  756. SUM(if(t.first_code = 4, 1, 0)) as first4,
  757. SUM(if(t.first_code = 5, 1, 0)) as first5,
  758. SUM(if(t.first_code = 6, 1, 0)) as first6,
  759. SUM(if(t.first_code = 7, 1, 0)) as first7,
  760. SUM(if(t.first_code = 8, 1, 0)) as first8,
  761. SUM(if(t.first_code = 9, 1, 0)) as first9,
  762. SUM(if(t.second_code = 0, 1, 0)) as second0,
  763. SUM(if(t.second_code = 1, 1, 0)) as second1,
  764. SUM(if(t.second_code = 2, 1, 0)) as second2,
  765. SUM(if(t.second_code = 3, 1, 0)) as second3,
  766. SUM(if(t.second_code = 4, 1, 0)) as second4,
  767. SUM(if(t.second_code = 5, 1, 0)) as second5,
  768. SUM(if(t.second_code = 6, 1, 0)) as second6,
  769. SUM(if(t.second_code = 7, 1, 0)) as second7,
  770. SUM(if(t.second_code = 8, 1, 0)) as second8,
  771. SUM(if(t.second_code = 9, 1, 0)) as second9,
  772. SUM(if(t.third_code = 0, 1, 0)) as third0,
  773. SUM(if(t.third_code = 1, 1, 0)) as third1,
  774. SUM(if(t.third_code = 2, 1, 0)) as third2,
  775. SUM(if(t.third_code = 3, 1, 0)) as third3,
  776. SUM(if(t.third_code = 4, 1, 0)) as third4,
  777. SUM(if(t.third_code = 5, 1, 0)) as third5,
  778. SUM(if(t.third_code = 6, 1, 0)) as third6,
  779. SUM(if(t.third_code = 7, 1, 0)) as third7,
  780. SUM(if(t.third_code = 8, 1, 0)) as third8,
  781. SUM(if(t.third_code = 9, 1, 0)) as third9,
  782. SUM(if(t.fourth_code = 0, 1, 0)) as fourth0,
  783. SUM(if(t.fourth_code = 1, 1, 0)) as fourth1,
  784. SUM(if(t.fourth_code = 2, 1, 0)) as fourth2,
  785. SUM(if(t.fourth_code = 3, 1, 0)) as fourth3,
  786. SUM(if(t.fourth_code = 4, 1, 0)) as fourth4,
  787. SUM(if(t.fourth_code = 5, 1, 0)) as fourth5,
  788. SUM(if(t.fourth_code = 6, 1, 0)) as fourth6,
  789. SUM(if(t.fourth_code = 7, 1, 0)) as fourth7,
  790. SUM(if(t.fourth_code = 8, 1, 0)) as fourth8,
  791. SUM(if(t.fourth_code = 9, 1, 0)) as fourth9,
  792. SUM(if(t.fifth_code = 0, 1, 0)) as fifth0,
  793. SUM(if(t.fifth_code = 1, 1, 0)) as fifth1,
  794. SUM(if(t.fifth_code = 2, 1, 0)) as fifth2,
  795. SUM(if(t.fifth_code = 3, 1, 0)) as fifth3,
  796. SUM(if(t.fifth_code = 4, 1, 0)) as fifth4,
  797. SUM(if(t.fifth_code = 5, 1, 0)) as fifth5,
  798. SUM(if(t.fifth_code = 6, 1, 0)) as fifth6,
  799. SUM(if(t.fifth_code = 7, 1, 0)) as fifth7,
  800. SUM(if(t.fifth_code = 8, 1, 0)) as fifth8,
  801. SUM(if(t.fifth_code = 9, 1, 0)) as fifth9
  802. from rank_five t
  803. join rank_five l on t.per_num = l.per_num + 1
  804. where l.first_code = #{firstCode} and l.per_num &lt; #{perNum}
  805. union
  806. select
  807. SUM(if(t.first_code = 0, 1, 0)) as first0,
  808. SUM(if(t.first_code = 1, 1, 0)) as first1,
  809. SUM(if(t.first_code = 2, 1, 0)) as first2,
  810. SUM(if(t.first_code = 3, 1, 0)) as first3,
  811. SUM(if(t.first_code = 4, 1, 0)) as first4,
  812. SUM(if(t.first_code = 5, 1, 0)) as first5,
  813. SUM(if(t.first_code = 6, 1, 0)) as first6,
  814. SUM(if(t.first_code = 7, 1, 0)) as first7,
  815. SUM(if(t.first_code = 8, 1, 0)) as first8,
  816. SUM(if(t.first_code = 9, 1, 0)) as first9,
  817. SUM(if(t.second_code = 0, 1, 0)) as second0,
  818. SUM(if(t.second_code = 1, 1, 0)) as second1,
  819. SUM(if(t.second_code = 2, 1, 0)) as second2,
  820. SUM(if(t.second_code = 3, 1, 0)) as second3,
  821. SUM(if(t.second_code = 4, 1, 0)) as second4,
  822. SUM(if(t.second_code = 5, 1, 0)) as second5,
  823. SUM(if(t.second_code = 6, 1, 0)) as second6,
  824. SUM(if(t.second_code = 7, 1, 0)) as second7,
  825. SUM(if(t.second_code = 8, 1, 0)) as second8,
  826. SUM(if(t.second_code = 9, 1, 0)) as second9,
  827. SUM(if(t.third_code = 0, 1, 0)) as third0,
  828. SUM(if(t.third_code = 1, 1, 0)) as third1,
  829. SUM(if(t.third_code = 2, 1, 0)) as third2,
  830. SUM(if(t.third_code = 3, 1, 0)) as third3,
  831. SUM(if(t.third_code = 4, 1, 0)) as third4,
  832. SUM(if(t.third_code = 5, 1, 0)) as third5,
  833. SUM(if(t.third_code = 6, 1, 0)) as third6,
  834. SUM(if(t.third_code = 7, 1, 0)) as third7,
  835. SUM(if(t.third_code = 8, 1, 0)) as third8,
  836. SUM(if(t.third_code = 9, 1, 0)) as third9,
  837. SUM(if(t.fourth_code = 0, 1, 0)) as fourth0,
  838. SUM(if(t.fourth_code = 1, 1, 0)) as fourth1,
  839. SUM(if(t.fourth_code = 2, 1, 0)) as fourth2,
  840. SUM(if(t.fourth_code = 3, 1, 0)) as fourth3,
  841. SUM(if(t.fourth_code = 4, 1, 0)) as fourth4,
  842. SUM(if(t.fourth_code = 5, 1, 0)) as fourth5,
  843. SUM(if(t.fourth_code = 6, 1, 0)) as fourth6,
  844. SUM(if(t.fourth_code = 7, 1, 0)) as fourth7,
  845. SUM(if(t.fourth_code = 8, 1, 0)) as fourth8,
  846. SUM(if(t.fourth_code = 9, 1, 0)) as fourth9,
  847. SUM(if(t.fifth_code = 0, 1, 0)) as fifth0,
  848. SUM(if(t.fifth_code = 1, 1, 0)) as fifth1,
  849. SUM(if(t.fifth_code = 2, 1, 0)) as fifth2,
  850. SUM(if(t.fifth_code = 3, 1, 0)) as fifth3,
  851. SUM(if(t.fifth_code = 4, 1, 0)) as fifth4,
  852. SUM(if(t.fifth_code = 5, 1, 0)) as fifth5,
  853. SUM(if(t.fifth_code = 6, 1, 0)) as fifth6,
  854. SUM(if(t.fifth_code = 7, 1, 0)) as fifth7,
  855. SUM(if(t.fifth_code = 8, 1, 0)) as fifth8,
  856. SUM(if(t.fifth_code = 9, 1, 0)) as fifth9
  857. from rank_five t
  858. join rank_five l on t.per_num = l.per_num + 1
  859. where l.second_code = #{secondCode} and l.per_num &lt; #{perNum}
  860. union
  861. select
  862. SUM(if(t.first_code = 0, 1, 0)) as first0,
  863. SUM(if(t.first_code = 1, 1, 0)) as first1,
  864. SUM(if(t.first_code = 2, 1, 0)) as first2,
  865. SUM(if(t.first_code = 3, 1, 0)) as first3,
  866. SUM(if(t.first_code = 4, 1, 0)) as first4,
  867. SUM(if(t.first_code = 5, 1, 0)) as first5,
  868. SUM(if(t.first_code = 6, 1, 0)) as first6,
  869. SUM(if(t.first_code = 7, 1, 0)) as first7,
  870. SUM(if(t.first_code = 8, 1, 0)) as first8,
  871. SUM(if(t.first_code = 9, 1, 0)) as first9,
  872. SUM(if(t.second_code = 0, 1, 0)) as second0,
  873. SUM(if(t.second_code = 1, 1, 0)) as second1,
  874. SUM(if(t.second_code = 2, 1, 0)) as second2,
  875. SUM(if(t.second_code = 3, 1, 0)) as second3,
  876. SUM(if(t.second_code = 4, 1, 0)) as second4,
  877. SUM(if(t.second_code = 5, 1, 0)) as second5,
  878. SUM(if(t.second_code = 6, 1, 0)) as second6,
  879. SUM(if(t.second_code = 7, 1, 0)) as second7,
  880. SUM(if(t.second_code = 8, 1, 0)) as second8,
  881. SUM(if(t.second_code = 9, 1, 0)) as second9,
  882. SUM(if(t.third_code = 0, 1, 0)) as third0,
  883. SUM(if(t.third_code = 1, 1, 0)) as third1,
  884. SUM(if(t.third_code = 2, 1, 0)) as third2,
  885. SUM(if(t.third_code = 3, 1, 0)) as third3,
  886. SUM(if(t.third_code = 4, 1, 0)) as third4,
  887. SUM(if(t.third_code = 5, 1, 0)) as third5,
  888. SUM(if(t.third_code = 6, 1, 0)) as third6,
  889. SUM(if(t.third_code = 7, 1, 0)) as third7,
  890. SUM(if(t.third_code = 8, 1, 0)) as third8,
  891. SUM(if(t.third_code = 9, 1, 0)) as third9,
  892. SUM(if(t.fourth_code = 0, 1, 0)) as fourth0,
  893. SUM(if(t.fourth_code = 1, 1, 0)) as fourth1,
  894. SUM(if(t.fourth_code = 2, 1, 0)) as fourth2,
  895. SUM(if(t.fourth_code = 3, 1, 0)) as fourth3,
  896. SUM(if(t.fourth_code = 4, 1, 0)) as fourth4,
  897. SUM(if(t.fourth_code = 5, 1, 0)) as fourth5,
  898. SUM(if(t.fourth_code = 6, 1, 0)) as fourth6,
  899. SUM(if(t.fourth_code = 7, 1, 0)) as fourth7,
  900. SUM(if(t.fourth_code = 8, 1, 0)) as fourth8,
  901. SUM(if(t.fourth_code = 9, 1, 0)) as fourth9,
  902. SUM(if(t.fifth_code = 0, 1, 0)) as fifth0,
  903. SUM(if(t.fifth_code = 1, 1, 0)) as fifth1,
  904. SUM(if(t.fifth_code = 2, 1, 0)) as fifth2,
  905. SUM(if(t.fifth_code = 3, 1, 0)) as fifth3,
  906. SUM(if(t.fifth_code = 4, 1, 0)) as fifth4,
  907. SUM(if(t.fifth_code = 5, 1, 0)) as fifth5,
  908. SUM(if(t.fifth_code = 6, 1, 0)) as fifth6,
  909. SUM(if(t.fifth_code = 7, 1, 0)) as fifth7,
  910. SUM(if(t.fifth_code = 8, 1, 0)) as fifth8,
  911. SUM(if(t.fifth_code = 9, 1, 0)) as fifth9
  912. from rank_five t
  913. join rank_five l on t.per_num = l.per_num + 1
  914. where l.third_code = #{thirdCode} and l.per_num &lt; #{perNum}
  915. union
  916. select
  917. SUM(if(t.first_code = 0, 1, 0)) as first0,
  918. SUM(if(t.first_code = 1, 1, 0)) as first1,
  919. SUM(if(t.first_code = 2, 1, 0)) as first2,
  920. SUM(if(t.first_code = 3, 1, 0)) as first3,
  921. SUM(if(t.first_code = 4, 1, 0)) as first4,
  922. SUM(if(t.first_code = 5, 1, 0)) as first5,
  923. SUM(if(t.first_code = 6, 1, 0)) as first6,
  924. SUM(if(t.first_code = 7, 1, 0)) as first7,
  925. SUM(if(t.first_code = 8, 1, 0)) as first8,
  926. SUM(if(t.first_code = 9, 1, 0)) as first9,
  927. SUM(if(t.second_code = 0, 1, 0)) as second0,
  928. SUM(if(t.second_code = 1, 1, 0)) as second1,
  929. SUM(if(t.second_code = 2, 1, 0)) as second2,
  930. SUM(if(t.second_code = 3, 1, 0)) as second3,
  931. SUM(if(t.second_code = 4, 1, 0)) as second4,
  932. SUM(if(t.second_code = 5, 1, 0)) as second5,
  933. SUM(if(t.second_code = 6, 1, 0)) as second6,
  934. SUM(if(t.second_code = 7, 1, 0)) as second7,
  935. SUM(if(t.second_code = 8, 1, 0)) as second8,
  936. SUM(if(t.second_code = 9, 1, 0)) as second9,
  937. SUM(if(t.third_code = 0, 1, 0)) as third0,
  938. SUM(if(t.third_code = 1, 1, 0)) as third1,
  939. SUM(if(t.third_code = 2, 1, 0)) as third2,
  940. SUM(if(t.third_code = 3, 1, 0)) as third3,
  941. SUM(if(t.third_code = 4, 1, 0)) as third4,
  942. SUM(if(t.third_code = 5, 1, 0)) as third5,
  943. SUM(if(t.third_code = 6, 1, 0)) as third6,
  944. SUM(if(t.third_code = 7, 1, 0)) as third7,
  945. SUM(if(t.third_code = 8, 1, 0)) as third8,
  946. SUM(if(t.third_code = 9, 1, 0)) as third9,
  947. SUM(if(t.fourth_code = 0, 1, 0)) as fourth0,
  948. SUM(if(t.fourth_code = 1, 1, 0)) as fourth1,
  949. SUM(if(t.fourth_code = 2, 1, 0)) as fourth2,
  950. SUM(if(t.fourth_code = 3, 1, 0)) as fourth3,
  951. SUM(if(t.fourth_code = 4, 1, 0)) as fourth4,
  952. SUM(if(t.fourth_code = 5, 1, 0)) as fourth5,
  953. SUM(if(t.fourth_code = 6, 1, 0)) as fourth6,
  954. SUM(if(t.fourth_code = 7, 1, 0)) as fourth7,
  955. SUM(if(t.fourth_code = 8, 1, 0)) as fourth8,
  956. SUM(if(t.fourth_code = 9, 1, 0)) as fourth9,
  957. SUM(if(t.fifth_code = 0, 1, 0)) as fifth0,
  958. SUM(if(t.fifth_code = 1, 1, 0)) as fifth1,
  959. SUM(if(t.fifth_code = 2, 1, 0)) as fifth2,
  960. SUM(if(t.fifth_code = 3, 1, 0)) as fifth3,
  961. SUM(if(t.fifth_code = 4, 1, 0)) as fifth4,
  962. SUM(if(t.fifth_code = 5, 1, 0)) as fifth5,
  963. SUM(if(t.fifth_code = 6, 1, 0)) as fifth6,
  964. SUM(if(t.fifth_code = 7, 1, 0)) as fifth7,
  965. SUM(if(t.fifth_code = 8, 1, 0)) as fifth8,
  966. SUM(if(t.fifth_code = 9, 1, 0)) as fifth9
  967. from rank_five t
  968. join rank_five l on t.per_num = l.per_num + 1
  969. where l.fourth_code = #{fourthCode} and l.per_num &lt; #{perNum}
  970. union
  971. select
  972. SUM(if(t.first_code = 0, 1, 0)) as first0,
  973. SUM(if(t.first_code = 1, 1, 0)) as first1,
  974. SUM(if(t.first_code = 2, 1, 0)) as first2,
  975. SUM(if(t.first_code = 3, 1, 0)) as first3,
  976. SUM(if(t.first_code = 4, 1, 0)) as first4,
  977. SUM(if(t.first_code = 5, 1, 0)) as first5,
  978. SUM(if(t.first_code = 6, 1, 0)) as first6,
  979. SUM(if(t.first_code = 7, 1, 0)) as first7,
  980. SUM(if(t.first_code = 8, 1, 0)) as first8,
  981. SUM(if(t.first_code = 9, 1, 0)) as first9,
  982. SUM(if(t.second_code = 0, 1, 0)) as second0,
  983. SUM(if(t.second_code = 1, 1, 0)) as second1,
  984. SUM(if(t.second_code = 2, 1, 0)) as second2,
  985. SUM(if(t.second_code = 3, 1, 0)) as second3,
  986. SUM(if(t.second_code = 4, 1, 0)) as second4,
  987. SUM(if(t.second_code = 5, 1, 0)) as second5,
  988. SUM(if(t.second_code = 6, 1, 0)) as second6,
  989. SUM(if(t.second_code = 7, 1, 0)) as second7,
  990. SUM(if(t.second_code = 8, 1, 0)) as second8,
  991. SUM(if(t.second_code = 9, 1, 0)) as second9,
  992. SUM(if(t.third_code = 0, 1, 0)) as third0,
  993. SUM(if(t.third_code = 1, 1, 0)) as third1,
  994. SUM(if(t.third_code = 2, 1, 0)) as third2,
  995. SUM(if(t.third_code = 3, 1, 0)) as third3,
  996. SUM(if(t.third_code = 4, 1, 0)) as third4,
  997. SUM(if(t.third_code = 5, 1, 0)) as third5,
  998. SUM(if(t.third_code = 6, 1, 0)) as third6,
  999. SUM(if(t.third_code = 7, 1, 0)) as third7,
  1000. SUM(if(t.third_code = 8, 1, 0)) as third8,
  1001. SUM(if(t.third_code = 9, 1, 0)) as third9,
  1002. SUM(if(t.fourth_code = 0, 1, 0)) as fourth0,
  1003. SUM(if(t.fourth_code = 1, 1, 0)) as fourth1,
  1004. SUM(if(t.fourth_code = 2, 1, 0)) as fourth2,
  1005. SUM(if(t.fourth_code = 3, 1, 0)) as fourth3,
  1006. SUM(if(t.fourth_code = 4, 1, 0)) as fourth4,
  1007. SUM(if(t.fourth_code = 5, 1, 0)) as fourth5,
  1008. SUM(if(t.fourth_code = 6, 1, 0)) as fourth6,
  1009. SUM(if(t.fourth_code = 7, 1, 0)) as fourth7,
  1010. SUM(if(t.fourth_code = 8, 1, 0)) as fourth8,
  1011. SUM(if(t.fourth_code = 9, 1, 0)) as fourth9,
  1012. SUM(if(t.fifth_code = 0, 1, 0)) as fifth0,
  1013. SUM(if(t.fifth_code = 1, 1, 0)) as fifth1,
  1014. SUM(if(t.fifth_code = 2, 1, 0)) as fifth2,
  1015. SUM(if(t.fifth_code = 3, 1, 0)) as fifth3,
  1016. SUM(if(t.fifth_code = 4, 1, 0)) as fifth4,
  1017. SUM(if(t.fifth_code = 5, 1, 0)) as fifth5,
  1018. SUM(if(t.fifth_code = 6, 1, 0)) as fifth6,
  1019. SUM(if(t.fifth_code = 7, 1, 0)) as fifth7,
  1020. SUM(if(t.fifth_code = 8, 1, 0)) as fifth8,
  1021. SUM(if(t.fifth_code = 9, 1, 0)) as fifth9
  1022. from rank_five t
  1023. join rank_five l on t.per_num = l.per_num + 1
  1024. where l.fifth_code = #{fifthCode} and l.per_num &lt; #{perNum};
  1025. </select>
  1026. <select id="queryRankFiveCodeNumByCodeAndPerNum" parameterType="com.e3.zl.wc.model.RankFive" resultMap="CBResultMap">
  1027. select
  1028. SUM(if(t.first_code = 0, 1, 0)) as first0,
  1029. SUM(if(t.first_code = 1, 1, 0)) as first1,
  1030. SUM(if(t.first_code = 2, 1, 0)) as first2,
  1031. SUM(if(t.first_code = 3, 1, 0)) as first3,
  1032. SUM(if(t.first_code = 4, 1, 0)) as first4,
  1033. SUM(if(t.first_code = 5, 1, 0)) as first5,
  1034. SUM(if(t.first_code = 6, 1, 0)) as first6,
  1035. SUM(if(t.first_code = 7, 1, 0)) as first7,
  1036. SUM(if(t.first_code = 8, 1, 0)) as first8,
  1037. SUM(if(t.first_code = 9, 1, 0)) as first9,
  1038. SUM(if(t.second_code = 0, 1, 0)) as second0,
  1039. SUM(if(t.second_code = 1, 1, 0)) as second1,
  1040. SUM(if(t.second_code = 2, 1, 0)) as second2,
  1041. SUM(if(t.second_code = 3, 1, 0)) as second3,
  1042. SUM(if(t.second_code = 4, 1, 0)) as second4,
  1043. SUM(if(t.second_code = 5, 1, 0)) as second5,
  1044. SUM(if(t.second_code = 6, 1, 0)) as second6,
  1045. SUM(if(t.second_code = 7, 1, 0)) as second7,
  1046. SUM(if(t.second_code = 8, 1, 0)) as second8,
  1047. SUM(if(t.second_code = 9, 1, 0)) as second9,
  1048. SUM(if(t.third_code = 0, 1, 0)) as third0,
  1049. SUM(if(t.third_code = 1, 1, 0)) as third1,
  1050. SUM(if(t.third_code = 2, 1, 0)) as third2,
  1051. SUM(if(t.third_code = 3, 1, 0)) as third3,
  1052. SUM(if(t.third_code = 4, 1, 0)) as third4,
  1053. SUM(if(t.third_code = 5, 1, 0)) as third5,
  1054. SUM(if(t.third_code = 6, 1, 0)) as third6,
  1055. SUM(if(t.third_code = 7, 1, 0)) as third7,
  1056. SUM(if(t.third_code = 8, 1, 0)) as third8,
  1057. SUM(if(t.third_code = 9, 1, 0)) as third9,
  1058. SUM(if(t.fourth_code = 0, 1, 0)) as fourth0,
  1059. SUM(if(t.fourth_code = 1, 1, 0)) as fourth1,
  1060. SUM(if(t.fourth_code = 2, 1, 0)) as fourth2,
  1061. SUM(if(t.fourth_code = 3, 1, 0)) as fourth3,
  1062. SUM(if(t.fourth_code = 4, 1, 0)) as fourth4,
  1063. SUM(if(t.fourth_code = 5, 1, 0)) as fourth5,
  1064. SUM(if(t.fourth_code = 6, 1, 0)) as fourth6,
  1065. SUM(if(t.fourth_code = 7, 1, 0)) as fourth7,
  1066. SUM(if(t.fourth_code = 8, 1, 0)) as fourth8,
  1067. SUM(if(t.fourth_code = 9, 1, 0)) as fourth9,
  1068. SUM(if(t.fifth_code = 0, 1, 0)) as fifth0,
  1069. SUM(if(t.fifth_code = 1, 1, 0)) as fifth1,
  1070. SUM(if(t.fifth_code = 2, 1, 0)) as fifth2,
  1071. SUM(if(t.fifth_code = 3, 1, 0)) as fifth3,
  1072. SUM(if(t.fifth_code = 4, 1, 0)) as fifth4,
  1073. SUM(if(t.fifth_code = 5, 1, 0)) as fifth5,
  1074. SUM(if(t.fifth_code = 6, 1, 0)) as fifth6,
  1075. SUM(if(t.fifth_code = 7, 1, 0)) as fifth7,
  1076. SUM(if(t.fifth_code = 8, 1, 0)) as fifth8,
  1077. SUM(if(t.fifth_code = 9, 1, 0)) as fifth9
  1078. from rank_five t
  1079. join rank_five l on t.per_num = l.per_num + 1
  1080. where l.per_num &lt; #{perNum}
  1081. <if test="firstCode != null">
  1082. and l.first_code = #{firstCode}
  1083. </if>
  1084. <if test="secondCode != null">
  1085. and l.second_code = #{secondCode}
  1086. </if>
  1087. <if test="thirdCode != null">
  1088. and l.third_code = #{thirdCode}
  1089. </if>
  1090. <if test="fourthCode != null">
  1091. and l.fourth_code = #{fourthCode}
  1092. </if>
  1093. <if test="fifthCode != null">
  1094. and l.fifth_code = #{fifthCode}
  1095. </if>
  1096. </select>
  1097. <select id="queryRankFiveHistoryCodeNum" parameterType="java.lang.Integer" resultMap="CBResultMap">
  1098. select
  1099. SUM(if(first_code = 0, 1, 0)) as first0,
  1100. SUM(if(first_code = 1, 1, 0)) as first1,
  1101. SUM(if(first_code = 2, 1, 0)) as first2,
  1102. SUM(if(first_code = 3, 1, 0)) as first3,
  1103. SUM(if(first_code = 4, 1, 0)) as first4,
  1104. SUM(if(first_code = 5, 1, 0)) as first5,
  1105. SUM(if(first_code = 6, 1, 0)) as first6,
  1106. SUM(if(first_code = 7, 1, 0)) as first7,
  1107. SUM(if(first_code = 8, 1, 0)) as first8,
  1108. SUM(if(first_code = 9, 1, 0)) as first9,
  1109. SUM(if(second_code = 0, 1, 0)) as second0,
  1110. SUM(if(second_code = 1, 1, 0)) as second1,
  1111. SUM(if(second_code = 2, 1, 0)) as second2,
  1112. SUM(if(second_code = 3, 1, 0)) as second3,
  1113. SUM(if(second_code = 4, 1, 0)) as second4,
  1114. SUM(if(second_code = 5, 1, 0)) as second5,
  1115. SUM(if(second_code = 6, 1, 0)) as second6,
  1116. SUM(if(second_code = 7, 1, 0)) as second7,
  1117. SUM(if(second_code = 8, 1, 0)) as second8,
  1118. SUM(if(second_code = 9, 1, 0)) as second9,
  1119. SUM(if(third_code = 0, 1, 0)) as third0,
  1120. SUM(if(third_code = 1, 1, 0)) as third1,
  1121. SUM(if(third_code = 2, 1, 0)) as third2,
  1122. SUM(if(third_code = 3, 1, 0)) as third3,
  1123. SUM(if(third_code = 4, 1, 0)) as third4,
  1124. SUM(if(third_code = 5, 1, 0)) as third5,
  1125. SUM(if(third_code = 6, 1, 0)) as third6,
  1126. SUM(if(third_code = 7, 1, 0)) as third7,
  1127. SUM(if(third_code = 8, 1, 0)) as third8,
  1128. SUM(if(third_code = 9, 1, 0)) as third9,
  1129. SUM(if(fourth_code = 0, 1, 0)) as fourth0,
  1130. SUM(if(fourth_code = 1, 1, 0)) as fourth1,
  1131. SUM(if(fourth_code = 2, 1, 0)) as fourth2,
  1132. SUM(if(fourth_code = 3, 1, 0)) as fourth3,
  1133. SUM(if(fourth_code = 4, 1, 0)) as fourth4,
  1134. SUM(if(fourth_code = 5, 1, 0)) as fourth5,
  1135. SUM(if(fourth_code = 6, 1, 0)) as fourth6,
  1136. SUM(if(fourth_code = 7, 1, 0)) as fourth7,
  1137. SUM(if(fourth_code = 8, 1, 0)) as fourth8,
  1138. SUM(if(fourth_code = 9, 1, 0)) as fourth9,
  1139. SUM(if(fifth_code = 0, 1, 0)) as fifth0,
  1140. SUM(if(fifth_code = 1, 1, 0)) as fifth1,
  1141. SUM(if(fifth_code = 2, 1, 0)) as fifth2,
  1142. SUM(if(fifth_code = 3, 1, 0)) as fifth3,
  1143. SUM(if(fifth_code = 4, 1, 0)) as fifth4,
  1144. SUM(if(fifth_code = 5, 1, 0)) as fifth5,
  1145. SUM(if(fifth_code = 6, 1, 0)) as fifth6,
  1146. SUM(if(fifth_code = 7, 1, 0)) as fifth7,
  1147. SUM(if(fifth_code = 8, 1, 0)) as fifth8,
  1148. SUM(if(fifth_code = 9, 1, 0)) as fifth9
  1149. from rank_five
  1150. where per_num &lt; #{perNum};
  1151. </select>
  1152. <select id="queryRankFiveHiatusCodeNum" parameterType="java.lang.Integer" resultMap="CHResultMap">
  1153. select o.*,
  1154. (select max(rf0.per_num) from rank_five rf0 where rf0.first_code = 0 and rf0.per_num &lt; o.per_num) as fc0,
  1155. (select max(rf1.per_num) from rank_five rf1 where rf1.first_code = 1 and rf1.per_num &lt; o.per_num) as fc1,
  1156. (select max(rf2.per_num) from rank_five rf2 where rf2.first_code = 2 and rf2.per_num &lt; o.per_num) as fc2,
  1157. (select max(rf3.per_num) from rank_five rf3 where rf3.first_code = 3 and rf3.per_num &lt; o.per_num) as fc3,
  1158. (select max(rf4.per_num) from rank_five rf4 where rf4.first_code = 4 and rf4.per_num &lt; o.per_num) as fc4,
  1159. (select max(rf5.per_num) from rank_five rf5 where rf5.first_code = 5 and rf5.per_num &lt; o.per_num) as fc5,
  1160. (select max(rf6.per_num) from rank_five rf6 where rf6.first_code = 6 and rf6.per_num &lt; o.per_num) as fc6,
  1161. (select max(rf7.per_num) from rank_five rf7 where rf7.first_code = 7 and rf7.per_num &lt; o.per_num) as fc7,
  1162. (select max(rf8.per_num) from rank_five rf8 where rf8.first_code = 8 and rf8.per_num &lt; o.per_num) as fc8,
  1163. (select max(rf9.per_num) from rank_five rf9 where rf9.first_code = 9 and rf9.per_num &lt; o.per_num) as fc9,
  1164. (select max(rfs0.per_num) from rank_five rfs0 where rfs0.second_code = 0 and rfs0.per_num &lt; o.per_num) as sc0,
  1165. (select max(rfs1.per_num) from rank_five rfs1 where rfs1.second_code = 1 and rfs1.per_num &lt; o.per_num) as sc1,
  1166. (select max(rfs2.per_num) from rank_five rfs2 where rfs2.second_code = 2 and rfs2.per_num &lt; o.per_num) as sc2,
  1167. (select max(rfs3.per_num) from rank_five rfs3 where rfs3.second_code = 3 and rfs3.per_num &lt; o.per_num) as sc3,
  1168. (select max(rfs4.per_num) from rank_five rfs4 where rfs4.second_code = 4 and rfs4.per_num &lt; o.per_num) as sc4,
  1169. (select max(rfs5.per_num) from rank_five rfs5 where rfs5.second_code = 5 and rfs5.per_num &lt; o.per_num) as sc5,
  1170. (select max(rfs6.per_num) from rank_five rfs6 where rfs6.second_code = 6 and rfs6.per_num &lt; o.per_num) as sc6,
  1171. (select max(rfs7.per_num) from rank_five rfs7 where rfs7.second_code = 7 and rfs7.per_num &lt; o.per_num) as sc7,
  1172. (select max(rfs8.per_num) from rank_five rfs8 where rfs8.second_code = 8 and rfs8.per_num &lt; o.per_num) as sc8,
  1173. (select max(rfs9.per_num) from rank_five rfs9 where rfs9.second_code = 9 and rfs9.per_num &lt; o.per_num) as sc9,
  1174. (select max(rft0.per_num) from rank_five rft0 where rft0.third_code = 0 and rft0.per_num &lt; o.per_num) as tc0,
  1175. (select max(rft1.per_num) from rank_five rft1 where rft1.third_code = 1 and rft1.per_num &lt; o.per_num) as tc1,
  1176. (select max(rft2.per_num) from rank_five rft2 where rft2.third_code = 2 and rft2.per_num &lt; o.per_num) as tc2,
  1177. (select max(rft3.per_num) from rank_five rft3 where rft3.third_code = 3 and rft3.per_num &lt; o.per_num) as tc3,
  1178. (select max(rft4.per_num) from rank_five rft4 where rft4.third_code = 4 and rft4.per_num &lt; o.per_num) as tc4,
  1179. (select max(rft5.per_num) from rank_five rft5 where rft5.third_code = 5 and rft5.per_num &lt; o.per_num) as tc5,
  1180. (select max(rft6.per_num) from rank_five rft6 where rft6.third_code = 6 and rft6.per_num &lt; o.per_num) as tc6,
  1181. (select max(rft7.per_num) from rank_five rft7 where rft7.third_code = 7 and rft7.per_num &lt; o.per_num) as tc7,
  1182. (select max(rft8.per_num) from rank_five rft8 where rft8.third_code = 8 and rft8.per_num &lt; o.per_num) as tc8,
  1183. (select max(rft9.per_num) from rank_five rft9 where rft9.third_code = 9 and rft9.per_num &lt; o.per_num) as tc9,
  1184. (select max(rfo0.per_num) from rank_five rfo0 where rfo0.fourth_code = 0 and rfo0.per_num &lt; o.per_num) as fo0,
  1185. (select max(rfo1.per_num) from rank_five rfo1 where rfo1.fourth_code = 1 and rfo1.per_num &lt; o.per_num) as fo1,
  1186. (select max(rfo2.per_num) from rank_five rfo2 where rfo2.fourth_code = 2 and rfo2.per_num &lt; o.per_num) as fo2,
  1187. (select max(rfo3.per_num) from rank_five rfo3 where rfo3.fourth_code = 3 and rfo3.per_num &lt; o.per_num) as fo3,
  1188. (select max(rfo4.per_num) from rank_five rfo4 where rfo4.fourth_code = 4 and rfo4.per_num &lt; o.per_num) as fo4,
  1189. (select max(rfo5.per_num) from rank_five rfo5 where rfo5.fourth_code = 5 and rfo5.per_num &lt; o.per_num) as fo5,
  1190. (select max(rfo6.per_num) from rank_five rfo6 where rfo6.fourth_code = 6 and rfo6.per_num &lt; o.per_num) as fo6,
  1191. (select max(rfo7.per_num) from rank_five rfo7 where rfo7.fourth_code = 7 and rfo7.per_num &lt; o.per_num) as fo7,
  1192. (select max(rfo8.per_num) from rank_five rfo8 where rfo8.fourth_code = 8 and rfo8.per_num &lt; o.per_num) as fo8,
  1193. (select max(rfo9.per_num) from rank_five rfo9 where rfo9.fourth_code = 9 and rfo9.per_num &lt; o.per_num) as fo9,
  1194. (select max(rfi0.per_num) from rank_five rfi0 where rfi0.fifth_code = 0 and rfi0.per_num &lt; o.per_num) as fi0,
  1195. (select max(rfi1.per_num) from rank_five rfi1 where rfi1.fifth_code = 1 and rfi1.per_num &lt; o.per_num) as fi1,
  1196. (select max(rfi2.per_num) from rank_five rfi2 where rfi2.fifth_code = 2 and rfi2.per_num &lt; o.per_num) as fi2,
  1197. (select max(rfi3.per_num) from rank_five rfi3 where rfi3.fifth_code = 3 and rfi3.per_num &lt; o.per_num) as fi3,
  1198. (select max(rfi4.per_num) from rank_five rfi4 where rfi4.fifth_code = 4 and rfi4.per_num &lt; o.per_num) as fi4,
  1199. (select max(rfi5.per_num) from rank_five rfi5 where rfi5.fifth_code = 5 and rfi5.per_num &lt; o.per_num) as fi5,
  1200. (select max(rfi6.per_num) from rank_five rfi6 where rfi6.fifth_code = 6 and rfi6.per_num &lt; o.per_num) as fi6,
  1201. (select max(rfi7.per_num) from rank_five rfi7 where rfi7.fifth_code = 7 and rfi7.per_num &lt; o.per_num) as fi7,
  1202. (select max(rfi8.per_num) from rank_five rfi8 where rfi8.fifth_code = 8 and rfi8.per_num &lt; o.per_num) as fi8,
  1203. (select max(rfi9.per_num) from rank_five rfi9 where rfi9.fifth_code = 9 and rfi9.per_num &lt; o.per_num) as fi9
  1204. from rank_five o order by o.per_num desc limit 0, #{showNum};
  1205. </select>
  1206. <select id="getMaxRankFiveHiatusCodeNum" parameterType="java.lang.Integer" resultMap="CHResultMap">
  1207. select o.*,
  1208. (select max(rf0.per_num) from rank_five rf0 where rf0.first_code = 0 and rf0.per_num &lt; o.per_num) as fc0,
  1209. (select max(rf1.per_num) from rank_five rf1 where rf1.first_code = 1 and rf1.per_num &lt; o.per_num) as fc1,
  1210. (select max(rf2.per_num) from rank_five rf2 where rf2.first_code = 2 and rf2.per_num &lt; o.per_num) as fc2,
  1211. (select max(rf3.per_num) from rank_five rf3 where rf3.first_code = 3 and rf3.per_num &lt; o.per_num) as fc3,
  1212. (select max(rf4.per_num) from rank_five rf4 where rf4.first_code = 4 and rf4.per_num &lt; o.per_num) as fc4,
  1213. (select max(rf5.per_num) from rank_five rf5 where rf5.first_code = 5 and rf5.per_num &lt; o.per_num) as fc5,
  1214. (select max(rf6.per_num) from rank_five rf6 where rf6.first_code = 6 and rf6.per_num &lt; o.per_num) as fc6,
  1215. (select max(rf7.per_num) from rank_five rf7 where rf7.first_code = 7 and rf7.per_num &lt; o.per_num) as fc7,
  1216. (select max(rf8.per_num) from rank_five rf8 where rf8.first_code = 8 and rf8.per_num &lt; o.per_num) as fc8,
  1217. (select max(rf9.per_num) from rank_five rf9 where rf9.first_code = 9 and rf9.per_num &lt; o.per_num) as fc9,
  1218. (select max(rfs0.per_num) from rank_five rfs0 where rfs0.second_code = 0 and rfs0.per_num &lt; o.per_num) as sc0,
  1219. (select max(rfs1.per_num) from rank_five rfs1 where rfs1.second_code = 1 and rfs1.per_num &lt; o.per_num) as sc1,
  1220. (select max(rfs2.per_num) from rank_five rfs2 where rfs2.second_code = 2 and rfs2.per_num &lt; o.per_num) as sc2,
  1221. (select max(rfs3.per_num) from rank_five rfs3 where rfs3.second_code = 3 and rfs3.per_num &lt; o.per_num) as sc3,
  1222. (select max(rfs4.per_num) from rank_five rfs4 where rfs4.second_code = 4 and rfs4.per_num &lt; o.per_num) as sc4,
  1223. (select max(rfs5.per_num) from rank_five rfs5 where rfs5.second_code = 5 and rfs5.per_num &lt; o.per_num) as sc5,
  1224. (select max(rfs6.per_num) from rank_five rfs6 where rfs6.second_code = 6 and rfs6.per_num &lt; o.per_num) as sc6,
  1225. (select max(rfs7.per_num) from rank_five rfs7 where rfs7.second_code = 7 and rfs7.per_num &lt; o.per_num) as sc7,
  1226. (select max(rfs8.per_num) from rank_five rfs8 where rfs8.second_code = 8 and rfs8.per_num &lt; o.per_num) as sc8,
  1227. (select max(rfs9.per_num) from rank_five rfs9 where rfs9.second_code = 9 and rfs9.per_num &lt; o.per_num) as sc9,
  1228. (select max(rft0.per_num) from rank_five rft0 where rft0.third_code = 0 and rft0.per_num &lt; o.per_num) as tc0,
  1229. (select max(rft1.per_num) from rank_five rft1 where rft1.third_code = 1 and rft1.per_num &lt; o.per_num) as tc1,
  1230. (select max(rft2.per_num) from rank_five rft2 where rft2.third_code = 2 and rft2.per_num &lt; o.per_num) as tc2,
  1231. (select max(rft3.per_num) from rank_five rft3 where rft3.third_code = 3 and rft3.per_num &lt; o.per_num) as tc3,
  1232. (select max(rft4.per_num) from rank_five rft4 where rft4.third_code = 4 and rft4.per_num &lt; o.per_num) as tc4,
  1233. (select max(rft5.per_num) from rank_five rft5 where rft5.third_code = 5 and rft5.per_num &lt; o.per_num) as tc5,
  1234. (select max(rft6.per_num) from rank_five rft6 where rft6.third_code = 6 and rft6.per_num &lt; o.per_num) as tc6,
  1235. (select max(rft7.per_num) from rank_five rft7 where rft7.third_code = 7 and rft7.per_num &lt; o.per_num) as tc7,
  1236. (select max(rft8.per_num) from rank_five rft8 where rft8.third_code = 8 and rft8.per_num &lt; o.per_num) as tc8,
  1237. (select max(rft9.per_num) from rank_five rft9 where rft9.third_code = 9 and rft9.per_num &lt; o.per_num) as tc9,
  1238. (select max(rfo0.per_num) from rank_five rfo0 where rfo0.fourth_code = 0 and rfo0.per_num &lt; o.per_num) as fo0,
  1239. (select max(rfo1.per_num) from rank_five rfo1 where rfo1.fourth_code = 1 and rfo1.per_num &lt; o.per_num) as fo1,
  1240. (select max(rfo2.per_num) from rank_five rfo2 where rfo2.fourth_code = 2 and rfo2.per_num &lt; o.per_num) as fo2,
  1241. (select max(rfo3.per_num) from rank_five rfo3 where rfo3.fourth_code = 3 and rfo3.per_num &lt; o.per_num) as fo3,
  1242. (select max(rfo4.per_num) from rank_five rfo4 where rfo4.fourth_code = 4 and rfo4.per_num &lt; o.per_num) as fo4,
  1243. (select max(rfo5.per_num) from rank_five rfo5 where rfo5.fourth_code = 5 and rfo5.per_num &lt; o.per_num) as fo5,
  1244. (select max(rfo6.per_num) from rank_five rfo6 where rfo6.fourth_code = 6 and rfo6.per_num &lt; o.per_num) as fo6,
  1245. (select max(rfo7.per_num) from rank_five rfo7 where rfo7.fourth_code = 7 and rfo7.per_num &lt; o.per_num) as fo7,
  1246. (select max(rfo8.per_num) from rank_five rfo8 where rfo8.fourth_code = 8 and rfo8.per_num &lt; o.per_num) as fo8,
  1247. (select max(rfo9.per_num) from rank_five rfo9 where rfo9.fourth_code = 9 and rfo9.per_num &lt; o.per_num) as fo9,
  1248. (select max(rfi0.per_num) from rank_five rfi0 where rfi0.fifth_code = 0 and rfi0.per_num &lt; o.per_num) as fi0,
  1249. (select max(rfi1.per_num) from rank_five rfi1 where rfi1.fifth_code = 1 and rfi1.per_num &lt; o.per_num) as fi1,
  1250. (select max(rfi2.per_num) from rank_five rfi2 where rfi2.fifth_code = 2 and rfi2.per_num &lt; o.per_num) as fi2,
  1251. (select max(rfi3.per_num) from rank_five rfi3 where rfi3.fifth_code = 3 and rfi3.per_num &lt; o.per_num) as fi3,
  1252. (select max(rfi4.per_num) from rank_five rfi4 where rfi4.fifth_code = 4 and rfi4.per_num &lt; o.per_num) as fi4,
  1253. (select max(rfi5.per_num) from rank_five rfi5 where rfi5.fifth_code = 5 and rfi5.per_num &lt; o.per_num) as fi5,
  1254. (select max(rfi6.per_num) from rank_five rfi6 where rfi6.fifth_code = 6 and rfi6.per_num &lt; o.per_num) as fi6,
  1255. (select max(rfi7.per_num) from rank_five rfi7 where rfi7.fifth_code = 7 and rfi7.per_num &lt; o.per_num) as fi7,
  1256. (select max(rfi8.per_num) from rank_five rfi8 where rfi8.fifth_code = 8 and rfi8.per_num &lt; o.per_num) as fi8,
  1257. (select max(rfi9.per_num) from rank_five rfi9 where rfi9.fifth_code = 9 and rfi9.per_num &lt; o.per_num) as fi9
  1258. from (select max(n.per_num) + 1 as per_num from rank_five n) o;
  1259. </select>
  1260. </mapper>