select t1.date as name, round(t2.part * 100 / t1.total, 2) as value from
(select FROM_UNIXTIME(r2.answer/1000,'%Y-%m-%d') as date, count(*) as total from t_qcp_first_aid a, t_qcp_first_aid_record r1 , t_qcp_first_aid_record r2
select t1.date as name, concat(round(t2.part * 100 / t1.total, 2), '%') as value from
(select
<choose>
<whentest="type == 0">FROM_UNIXTIME(r2.answer/1000,'%Y-%m-%d %H') as date,</when>
<whentest="type == 1">FROM_UNIXTIME(r2.answer/1000,'%Y-%m-%d') as date,</when>
<whentest="type == 2">FROM_UNIXTIME(r2.answer/1000,'%Y-%m') as date,</when>
<otherwise>FROM_UNIXTIME(r2.answer/1000,'%Y-%m-%d') as date,</otherwise>
</choose>
count(*) as total from t_qcp_first_aid a, t_qcp_first_aid_record r1 , t_qcp_first_aid_record r2
where a.id = r1.first_aid_id and r1.question_code = 'JBXX-FBSJ'
and a.id = r2.first_aid_id and r1.question_code = 'JBXX-DYSJ'
and r2.answer + 0 >= 0 and r2.answer + 0 <= 0
and a.hospital_id in (0)
and r2.answer - r1.answer < 6 * 60 * 60 * 1000
and a.rec_status = 0 and r1.rec_status = 0 and r2.rec_status = 0
group by FROM_UNIXTIME(r2.answer/1000,'%Y-%m-%d')) t1,
(select FROM_UNIXTIME(r2.answer/1000,'%Y-%m-%d') as date, count(a.id) as part from t_qcp_first_aid a, t_qcp_first_aid_record r1, t_qcp_first_aid_record r2
select b.id,b.shortName as name, avg(b.val) as value from
(select id,shortName,val,@team,
case @team when id then @rk := @rk + 1 else @rk := 1 end rk,
@team := id
from (
select city.id, city.short_name as shortName, aid.val from
(select city.id, city.short_name from t_organization o, t_organization_parent p, t_organization city
where o.id = p.parent_id and p.organization_id = city.id
and o.code = #{param.code} and o.rec_status = 0 and p.rec_status = 0 and city.rec_status = 0) city
left join
(select o.id, o.name, p.parent_id from t_organization o, t_organization_parent p where o.id = p.organization_id and o.organization_type = 3 and o.rec_status = 0 and p.rec_status = 0) hospital on city.id = hospital.parent_id
left join
(
select
a.hospital_id,
ROUND((r1.answer - r2.answer)/60000, 2) as val
from t_qcp_first_aid a, t_qcp_first_aid_record r1 , t_qcp_first_aid_record r2
where a.id = r1.first_aid_id and r1.question_code = #{param.minuendCode}
and a.id = r2.first_aid_id and r2.question_code = #{param.subtractionCode}
and r1.answer + 0 >= #{startTime} and r1.answer + 0 <= #{endTime}
and a.rec_status = 0 and r1.rec_status = 0 and r2.rec_status = 0
) aid on hospital.id = aid.hospital_id
) t1, (select @rk := 0, @team := '') a order by id,val) b
left join
(
select city.id, city.short_name as shortName, count(aid.id) as cnt from
(select city.id, city.short_name from t_organization o, t_organization_parent p, t_organization city
where o.id = p.parent_id and p.organization_id = city.id
and o.code = #{param.code} and o.rec_status = 0 and p.rec_status = 0 and city.rec_status = 0) city
left join
(select o.id, o.name, p.parent_id from t_organization o, t_organization_parent p where o.id = p.organization_id and o.organization_type = 3 and o.rec_status = 0 and p.rec_status = 0) hospital on city.id = hospital.parent_id
left join
(
select
a.id,
a.hospital_id,
ROUND((r1.answer - r2.answer)/60000, 2) as val
from t_qcp_first_aid a, t_qcp_first_aid_record r1 , t_qcp_first_aid_record r2
where a.id = r1.first_aid_id and r1.question_code = #{param.minuendCode}
and a.id = r2.first_aid_id and r2.question_code = #{param.subtractionCode}
and r1.answer + 0 >= #{startTime} and r1.answer + 0 <= #{endTime}
and a.rec_status = 0 and r1.rec_status = 0 and r2.rec_status = 0