<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.qxgmat.data.relation.UserRelationMapper">
  <resultMap id="Prepare" type="com.qxgmat.data.relation.entity.UserPrepareRelation">
    <!--
      WARNING - @mbg.generated
    -->
    <id column="i" jdbcType="INTEGER" property="i" />
    <id column="s" jdbcType="VARCHAR" property="s" />
    <id column="number" jdbcType="INTEGER" property="number" />
  </resultMap>
  <sql id="Id_Column_List">
    <!--
      WARNING - @mbg.generated
    -->
    ur.`id`
  </sql>

  <!--
    字符串字段统计
  -->
  <select id="groupPrepareString" resultMap="Prepare">
    select
      `${field}` as `s`, count(*) as `number`
    from `user`
    where
      `prepare_goal` > 0
    and `${field}` != null and `${field}` != ""
    group by `${field}`
  </select>

  <!--
    数字字段统计
  -->
  <select id="groupPrepareInteger" resultMap="Prepare">
    select
    `${field}` as `i`, count(*) as `number`
    from `user`
    where
    `prepare_goal` > 0
    and `${field}` > 0
    group by `${field}`
  </select>

</mapper>