select t1.tcustomer_receptid,
       t1.ftype,
       t1.fchannel,
       t1.fname,
       t1.fphonenumber,
       t1.fcommunity,
       t1.fnumber,
       t1.fwaiter,
       SUBSTRING(convert(varchar(19), t1.createdate, 120), 12, 5) ftime,
       case
           when convert(varchar(10), t1.createdate, 120) = convert(varchar(10), t2.createdate, 120) then 1
           else 0 end                                             fisnew
from tcustomer_reception t1
         inner join tcustomer t2
                    on t1.siteid = t2.siteid and t1.tagentsid = t2.tagentsid and t1.tcustomerid = t2.tcustomerid
where t1.siteid = $siteid$
  and t1.tagentsid = $tagentsid$
  and convert(varchar(10), t1.createdate, 120) = $fdate$ and $where$