select top(1) t1.fname, t2.fcompshortname, t3.fobsurl, t3.fobsurl_minimage
from tenterprise_users t1
         inner join tenterprise t2 on t1.siteid = t2.siteid
         left join tattachment t3 on t1.tenterprise_userid = t3.ownerid and t3.ownertable = 'tenterprise_users' and
                                     ftype = 'headportrait'
where t1.siteid = $siteid$
  and t1.tenterprise_userid = $tenterprise_userid$
order by tattachmentid desc
