select distinct t1.tnoticeid,
                t1.siteid,
                t2.fsaleruserid,
                t1.tenterprise_userid,
                t2.fsaler,
                t2.fname,
                t2.fprovince,
                t2.fcity,
                t2.fcounty,
                isnull(t2.fphonenumber,' ') as fphonenumber,
                case when t1.flastreadtime IS null then '未浏览' else '已浏览' end         freadstatus,
                case when t3.tenterprise_userid IS null then '未下载' else '已下载' end as fdownloadstatus
from tnotice_users t1
       inner join user_agent_saler_view t2 on t1.siteid = t2.siteid and t1.tenterprise_userid = t2.tenterprise_userid
       left join (
  select distinct t2.tenterprise_userid
  from tattachment t1
         inner join tattachment_downlog t2 on t1.siteid = t2.siteid and t1.tattachmentid = t2.tattachmentid
  where t1.siteid =$siteid$
    and t1.ownertable = 'tnotice'
    and t1.ownerid = $tnoticeid$
) t3 on t1.tenterprise_userid = t3.tenterprise_userid
where t1.siteid = $siteid$
  and t1.tnoticeid = $tnoticeid$
and t2.fsaleruserid in $fsaleruserid$