select count(distinct c) from rtneo$ContragentRealEstate c where not c.contragent.user is null and (select count(s) from sec$SessionLogEntry s where s.user.id = c.contragent.user.id) > 0 and (lower(c.realEstate.address) like lower('%%садовод%%') or lower(c.realEstate.address) like lower('%%товарищество%%'))