select c.name, c.legalAddress, (select ct.number from rtneo$Contract ct where ct.contragent.id = c.id and ct.mainContract is null) from rtneo$Contragent c where lower(c.legalAddress) like '%бодайбо%' and size(c.contracts) <=1 and (select count(p) from rtneo$Payment p where p.inn = c.inn)=0 and ((select count(s) from sec$SessionLogEntry s where c.user = s.user)=0 or c.user is null)