sql 統計整理

Pgsqlsql

 

字符字段轉整型查詢:mybatis

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 Tspa

 

mybatis in 查詢:code

<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:blog

子查詢it

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
相關文章
相關標籤/搜索