sql 统计整理

Pgsql

 

字符字段转整型查询:

SELECT mon_id as staTime,SUM (CAST ( index_value AS INT )) AS totalCount FROM aidata.rep_index_values_m 

  SELECT ext_dim1 sex, sum(index_value::NUMERIC) total FROM aidata.rep_index_values_y T

 

mybatis in 查询:

<if test="orgIdList != null">
            <if test="orgIdList.size() > 0">
                and org_id IN
                <foreach collection="orgIdList" item="item" open="("
                         separator="," close=")">
                    #{item}
                </foreach>
            </if>
        </if>

 

 

Mysql:

子查询

SELECT
        temp1.count AS total,
        temp2.count AS num1,
        temp3.count AS num2 
    FROM
    ( SELECT count( 1 ) AS count FROM t_e_xiexiexie WHERE STATUS = '1' ) temp1,
    ( SELECT count( 1 ) AS count FROM t_e_xiexiexie WHERE true AND createtime >= '2019-06-13' AND createtime < '2019-06-14' ) temp2,
    ( SELECT count( 1 ) AS count FROM t_e_xiexiexie WHERE STATUS = '9' AND lastmodifytime >= '2019-06-13' AND lastmodifytime < '2019-06-14' ) temp3

 

posted @ 2019-04-29 17:42  漫步CODE人生  阅读(238)  评论(0编辑  收藏  举报