Postgresql GROUP BY "SIMILAR" but not equal values

Поиск
Список
Период
Сортировка
От alexandros_e
Тема Postgresql GROUP BY "SIMILAR" but not equal values
Дата
Msg-id 1391699895790-5790860.post@n5.nabble.com
обсуждение исходный текст
Ответы Re: Postgresql GROUP BY "SIMILAR" but not equal values  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: Postgresql GROUP BY "SIMILAR" but not equal values  (Alban Hertroys <haramrae@gmail.com>)
Список pgsql-general
I wanted to ask you the following question to all experts here.

Let's say I have this table foo

ID|G1|T1|
1|2|ABC|
1|2|ABCD|
1|2|DEF|
1|2|DEFG|

SELECT * FROM foo
GROUP BY ID,G1,T1

RETURNS exactly the same table.

Is there a way in SQL or PostgreSQL in general to group by values than are
not exactly the same but are quite similar (like 'ABC' and 'ABCD') based on
some distance function (levenshtein for example) if the distance is within
some threshold (i.e., 1)

My intuition is that SQL cannot support such queries but I was wondering if
there was some hack around it. The problem as I see it that distance
functions require 2 values but GROUP BY only checks equality.

Another subproblem that might help is can we overload an operator of a
custom type, so that equals operator is more "relaxed" and is calculated by
a function?  OR can we use GROUP BY with a custom comparator for a data
type?

I hope my question makes sense.



--
View this message in context:
http://postgresql.1045698.n5.nabble.com/Postgresql-GROUP-BY-SIMILAR-but-not-equal-values-tp5790860.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.


В списке pgsql-general по дате отправления:

Предыдущее
От: Merlin Moncure
Дата:
Сообщение: Re: Offending My Tender Sensibilities -OR- OLTP on a Star Schema
Следующее
От: Merlin Moncure
Дата:
Сообщение: Re: Help with connection issue - started today