I have a question about this fiddle:
How do I group the objects in groups where all objects has the same two first words in "tmaname"? I.e. all 'ARAD %' shall be in one group etc.
I tried this:
SELECT substring(t1."tmaname" from '^\w\s\w') AS first_key_words
--, ST_MULTI(ST_UNION(ST_SnapToGrid(t1.the_geom, 0.000001))) AS geom
FROM "nisse" AS t1
GROUP BY substring(t1."tmaname" from '^\w\s\w')
But the query only returns first_key_words = null.
If the words in your case are always going to be separated by the same character (like a space, for instance), you could try using the [`split_part()`] function instead of regular expressions.