select top #_maxItems# cdr.cdr_recordid, cdr.cdr_dstname, cdr.cdr_dstcity, cdr.cdr_dststate from tbl_cdr_distributors cdr with (nolock) left outer join tbl_DST_Distributors dst with (nolock) on dst.dstid = cdr.FSL_dstid left outer join tbl_DST_Distributors pdst with (nolock) on pdst.dstid = dst.dstparentco where cdr.ownerid = and cdr.fsl_tablecode = and ( ( cdr.cdr_dstname like or cdr.cdr_dstcity like ) and 1 = 1 ) and cdr.crmactive = 'Y' and ( cdr.cdr_dstcompanytype in ( 'P', 'B' ) or cdr.cdr_dstcompanytype is null ) and cdr.cdr_territoryid in () and pdst.dstid in () order by cdr.cdr_dstname #_data#