select a.style,
ROUND
(
b.num / a.sum * 100,
2
)
as
styleRate from (SELECT
count
(qspc.id) sum
,qq.style style
from t_qc_security_plan_comment qspc
inner join t_qc_question qq
on qq.id = qspc.question_id
LEFT JOIN t_qc_address qa ON qa.id = qspc.address_id
LEFT JOIN t_system_organ so on qa.hospital = so.id
WHERE qq.scr_level is not NULL
and
qq.type = 3
and
so.tenant_code =
'zzyy'
GROUP BY style) a left join (SELECT
count
(qspc.id) num
,qq.style style
from t_qc_security_plan_comment qspc
inner join t_qc_question qq
on qq.id = qspc.question_id
LEFT JOIN t_qc_address qa ON qa.id = qspc.address_id
LEFT JOIN t_system_organ so on qa.hospital = so.id
WHERE qq.scr_level is not NULL
and
qq.type = 3
and
so.tenant_code =
'zzyy'
and
qspc.is_bad =0
GROUP BY style) b on a.style = b.style