Skip to content

Instantly share code, notes, and snippets.

@abevieiramota
Created May 9, 2019 22:55
Show Gist options
  • Save abevieiramota/5425f50f1746d83310cb469358454d2a to your computer and use it in GitHub Desktop.
Save abevieiramota/5425f50f1746d83310cb469358454d2a to your computer and use it in GitHub Desktop.
CREATE EXTENSION fuzzystrmatch;
create table nomes(nome) as
(values
('abelardo'),
('aberlado'),
('aberlardo'),
('jurandir'),
('jurandr'),
('abraão')
);
select levenshtein(n1.nome, n2.nome), array_agg(array[n1.nome, n2.nome])
from nomes n1, nomes n2
where n1.nome <> n2.nome and n1.nome > n2.nome
group by 1
order by 1 asc;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment