select distinct p.inn, p.kpp,
similarity(inn::text, '3801015727'::text),
dense_rank() OVER (ORDER BY similarity(inn::text, '3801015727') DESC) as rang
from rtneo_contragent p
where similarity(inn::text, '3801015727'::text) >0.3
ORDER BY similarity DESC;