select t5.intid,
t5.strelementname,
TT2.intobjectid,
t6.dblweight,
sum(TT2.score),
sum(TT2.finalScore),
t6.dblweight*sum(TT2.score) TotalScore
from
(
select
t2.intid,
t2.strelementname,
sum(t.dblscore) score,
t3.intobjectid,
t4.dblweight,
t4.dblweight*sum(t.dblscore) FinalScore,
t2.intparentid
from eva_score_detail t
inner join eva_score t3 on t.intmasterid=t3.intid and t3.inttemplateid=14
inner join eva_activity_elementdetail t1 on t.intelementdetailid = t1.intid
inner join
(
select K2.INTID from eva_evasetting_elements K
inner join eva_activity_element K1 on K.intelementid=K1.intid and K1.intparentid=0
inner join eva_activity_element K2 on K2.intparentid=K1.intid
where K.inttemplateid=14
union
select K3.INTID from eva_evasetting_elements K
inner join eva_activity_element K1 on K.intelementid=K1.intid and K1.intparentid=0
inner join eva_activity_element K2 on K2.intparentid=K1.intid
inner join eva_activity_element K3 on K3.intparentid=K3.intid
where K.inttemplateid=14
) TT on t1.intparentid=TT.INTID
inner join eva_activity_element t2 on t2.intid = TT.intid
inner join eva_evasetting_elements t4 on TT.intid=t4.intelementid and t4.inttemplateid=14
group by t2.intid, t2.strelementname,t3.intobjectid,t4.dblweight,t2.intparentid
) TT2
inner join eva_activity_element t5 on TT2.intparentid=t5.intid
inner join eva_evasetting_elements t6 on t5.intid=t6.intelementid and t6.inttemplateid=14
group by t5.intid,t6.dblweight,t5.strelementname,TT2.intobjectid
order by tt2.intobjectid,t5.intid
t5.strelementname,
TT2.intobjectid,
t6.dblweight,
sum(TT2.score),
sum(TT2.finalScore),
t6.dblweight*sum(TT2.score) TotalScore
from
(
select
t2.intid,
t2.strelementname,
sum(t.dblscore) score,
t3.intobjectid,
t4.dblweight,
t4.dblweight*sum(t.dblscore) FinalScore,
t2.intparentid
from eva_score_detail t
inner join eva_score t3 on t.intmasterid=t3.intid and t3.inttemplateid=14
inner join eva_activity_elementdetail t1 on t.intelementdetailid = t1.intid
inner join
(
select K2.INTID from eva_evasetting_elements K
inner join eva_activity_element K1 on K.intelementid=K1.intid and K1.intparentid=0
inner join eva_activity_element K2 on K2.intparentid=K1.intid
where K.inttemplateid=14
union
select K3.INTID from eva_evasetting_elements K
inner join eva_activity_element K1 on K.intelementid=K1.intid and K1.intparentid=0
inner join eva_activity_element K2 on K2.intparentid=K1.intid
inner join eva_activity_element K3 on K3.intparentid=K3.intid
where K.inttemplateid=14
) TT on t1.intparentid=TT.INTID
inner join eva_activity_element t2 on t2.intid = TT.intid
inner join eva_evasetting_elements t4 on TT.intid=t4.intelementid and t4.inttemplateid=14
group by t2.intid, t2.strelementname,t3.intobjectid,t4.dblweight,t2.intparentid
) TT2
inner join eva_activity_element t5 on TT2.intparentid=t5.intid
inner join eva_evasetting_elements t6 on t5.intid=t6.intelementid and t6.inttemplateid=14
group by t5.intid,t6.dblweight,t5.strelementname,TT2.intobjectid
order by tt2.intobjectid,t5.intid