select  case when t3.tattachment_downid IS null then '未下载'else'已下载'end as ftype,count(distinct t1.tenterprise_userid)as fcount
from tnotice_users t1
       inner join tattachment t2 on t1.siteid=t2.siteid and t2.ownertable='tnotice' and t2.ownerid=$tnoticeid$
       left join tattachment_downlog t3 on t2.siteid=t3.siteid and t2.tattachmentid=t3.tattachmentid and t1.tenterprise_userid=t3.tenterprise_userid
       inner join tenterprise_users t4 on t1.siteid=t4.siteid and t1.tenterprise_userid=t4.tenterprise_userid and t4.fusertype='企业'
where t1.siteid = $siteid$ and t1.tnoticeid=$tnoticeid$
group by case when t3.tattachment_downid IS null then '未下载'else'已下载'end