select t1.ftitle,
       t1.ftype,
       t1.checkdate,
       count(distinct t2.tenterprise_userid) freadcount,
       count(distinct t3.tenterprise_userid) fscorecount,
       AVG(t3.fscore)                        favgscore,
       t4.fdownloadcount fdownloadcount,
       convert(decimal(16,2),count(distinct t3.tenterprise_userid))/convert(float,case when count(distinct t2.tenterprise_userid)=0 then 1 else count(distinct t2.tenterprise_userid) end)*100 as fscorerate
from tnotice t1
       left join tnotice_users t2
                 on t1.siteid = t2.siteid and t1.tnoticeid = t2.tnoticeid and t2.flastreadtime is not null
       left join tnotice_users t3 on t1.siteid = t3.siteid and t1.tnoticeid = t3.tnoticeid and t3.fscore > 0
       left join (
                select t1.siteid,t1.ownerid,count(0)as fdownloadcount from tattachment t1
                inner join tattachment_downlog t2 on t1.siteid=t2.siteid and t1.tattachmentid=t2.tattachmentid
                where t1.ownertable='tnotice' and t1.siteid=$siteid$ group by t1.siteid,t1.ownerid
)t4 on t1.siteid=t4.siteid and t1.tnoticeid=t4.ownerid
where t1.siteid=$siteid$ and $where$ and t1.fstatus='·¢²¼'
group by t1.ftitle, t1.ftype, t1.checkdate,t4.fdownloadcount