Re: [GENERAL] Postgresql GROUP BY "SIMILAR" but not equal values

2014-02-06 Thread alexandros_e
Conceptually, Tom (as always) is right. But Alban's hack help. DROP TABLE foo; CREATE TABLE IF NOT EXISTS foo(ID INTEGER,G1 INTEGER, T1 TEXT, ID2 SERIAL PRIMARY KEY); INSERT INTO foo(ID,G1,T1) VALUES(1,2,'ABC'); INSERT INTO foo(ID,G1,T1) VALUES(1,2,'ABCD'); INSERT INTO foo(ID,G1,T1) VALUES(1,2,'A

Re: [GENERAL] Postgresql GROUP BY "SIMILAR" but not equal values

2014-02-06 Thread Gauthier, Dave
BY "SIMILAR" but not equal values alexandros_e writes: > 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 exa

Re: [GENERAL] Postgresql GROUP BY "SIMILAR" but not equal values

2014-02-06 Thread Sergey Konoplev
On Thu, Feb 6, 2014 at 7:41 AM, Alban Hertroys wrote: > On 6 February 2014 16:18, alexandros_e wrote: >> 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

Re: [GENERAL] Postgresql GROUP BY "SIMILAR" but not equal values

2014-02-06 Thread Alban Hertroys
On 6 February 2014 16:18, alexandros_e wrote: > 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 > Is there a way in SQL or PostgreSQL in general to group by values than are > not exactly the same but are quite s

Re: [GENERAL] Postgresql GROUP BY "SIMILAR" but not equal values

2014-02-06 Thread Tom Lane
alexandros_e writes: > 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) Well, you can GRO

[GENERAL] Postgresql GROUP BY "SIMILAR" but not equal values

2014-02-06 Thread alexandros_e
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 exa