select ownerid,
       case when isnull(t1.fobsurl_minimage, '') = '' then t1.fobsurl else t1.fobsurl_minimage end fobsurl,
       fobsurl_hls,
       fobsurl_compressimage,
       postfix
from tattachment t1
where t1.ownertable = $ownertable$
  and t1.siteid =$siteid$
  and t1.ownerid in $ownerid$
order by t1.createdate