增加sql按类型统计

0927cmt
zhaoyu 2024-05-07 11:26:47 +08:00
parent bb6c7d8361
commit 7806353850
1 changed files with 63 additions and 0 deletions

View File

@ -1018,6 +1018,69 @@
order by FIELD ( f.STATE, '-2' ) desc,<!-- 因为这是隐患确认列表有确认按钮的排在前面 -->
f.DISCOVERYTIME desc <!-- 剩下的按隐患发现时间排序 -->
</select>
<!-- 根据类型按照月份统计隐患数量 -->
<select id="goSummaryTypeTable" parameterType="pd" resultType="pd">
SELECT
wd.CREATE_MONTH,
wd.wdbaqztCount,
gl.gldqxCount,
hj.hjdbaqysCount,
rd.rdbaqysCount
FROM
(
SELECT
date_format( `f`.`CREATTIME`, '%Y-%m' ) AS `CREATE_MONTH`,
COUNT( f.HIDDEN_ID ) wdbaqztCount
FROM
`bus_hidden` f
WHERE
f.ISDELETE = '0'
AND date_format( f.`CREATTIME`, '%Y' ) = #{YEAR}
AND f.HIDDENTYPE IN ( SELECT BIANMA FROM `qa-cmt-prevention`.`sys_dictionaries` WHERE `PARENT_ID` = '8731b7fca94248c1b07d3ba8327b8e97' )
GROUP BY
CREATE_MONTH
) wd
LEFT JOIN (
SELECT
date_format( `f`.`CREATTIME`, '%Y-%m' ) AS `CREATE_MONTH`,
COUNT( f.HIDDEN_ID ) gldqxCount
FROM
`bus_hidden` f
WHERE
f.ISDELETE = '0'
AND date_format( f.`CREATTIME`, '%Y' ) = #{YEAR}
AND f.HIDDENTYPE IN ( SELECT BIANMA FROM `qa-cmt-prevention`.`sys_dictionaries` WHERE `PARENT_ID` = '99d384302d0c488a95e0edf456b6fa15' )
GROUP BY
CREATE_MONTH
) gl ON wd.CREATE_MONTH = gl.CREATE_MONTH
LEFT JOIN (
SELECT
date_format( `f`.`CREATTIME`, '%Y-%m' ) AS `CREATE_MONTH`,
COUNT( f.HIDDEN_ID ) hjdbaqysCount
FROM
`bus_hidden` f
WHERE
f.ISDELETE = '0'
AND date_format( f.`CREATTIME`, '%Y' ) = #{YEAR}
AND f.HIDDENTYPE IN ( SELECT BIANMA FROM `qa-cmt-prevention`.`sys_dictionaries` WHERE `PARENT_ID` = 'b8aa6a4916664ed08bd322ab5bb6b5f2' )
GROUP BY
CREATE_MONTH
) hj ON wd.CREATE_MONTH = hj.CREATE_MONTH
LEFT JOIN (
SELECT
date_format( `f`.`CREATTIME`, '%Y-%m' ) AS `CREATE_MONTH`,
COUNT( f.HIDDEN_ID ) rdbaqysCount
FROM
`bus_hidden` f
WHERE
f.ISDELETE = '0'
AND date_format( f.`CREATTIME`, '%Y' ) = #{YEAR}
AND f.HIDDENTYPE IN ( SELECT BIANMA FROM `qa-cmt-prevention`.`sys_dictionaries` WHERE `PARENT_ID` = 'f531c7a102c44734b007f18d029ebaec' )
GROUP BY
CREATE_MONTH
) rd ON wd.CREATE_MONTH = rd.CREATE_MONTH
</select>
</mapper>