select t1.tenterprise_userid, t2.fname, t2.fphonenumber,flastreadtime,count(t5.tnotice_userdataid)freadcount,
       sum(DATEDIFF(MINUTE,t5.createdate,t5.closedate)) freadtimes
from tnotice_users t1
       inner join tenterprise_users t2 on t1.siteid = t2.siteid and t1.tenterprise_userid = t2.tenterprise_userid  and t2.fusertype='ÆóÒµ'
       left join tnotice_userdata t5 on t1.siteid=t5.siteid and t1.tnoticeid=t5.tnoticeid and t1.tenterprise_userid=t5.tenterprise_userid
where t1.siteid = $siteid$ and t1.tnoticeid = $tnoticeid$
      and not exists(
        select tenterprise_userid from tattachment
        inner join tattachment_downlog  on tattachment.siteid=tattachment_downlog.siteid and tattachment.tattachmentid=tattachment_downlog.tattachmentid
        where  tattachment.siteid=t1.siteid and tattachment.ownertable='tnotice' and tattachment.ownerid=$tnoticeid$ and tattachment_downlog.tenterprise_userid=t1.tenterprise_userid
  )
group by t1.tnotice_usersid,t1.tenterprise_userid, t2.fname,t2.fphonenumber,flastreadtime
