求(answer_state=0的总数)/(answer_state的全部总数)
select sum(case when answer_state = 0 then 1 else 0 end)/count(answer_state) from (这里嵌套你的子查询就行)
select convert(decimal(18, 2),
(select count(*) from XXX where answer_state=0)
)
/
NULLIF(convert(decimal(18, 2),
(select count(*) from XXX )
select (sum(case when answer_state = 0 then 1 else 0 end)/count(1))as ZhengQueLv from 表