是否可以从Postgres中包含文本字符串的字段中识别每个字词和计数?
像这样的东西?
原文链接:https://www.f2er.com/postgresql/192087.htmlSELECT some_pk,regexp_split_to_table(some_column,'\s') as word FROM some_table
获得不同的单词很容易:
SELECT DISTINCT word FROM ( SELECT regexp_split_to_table(some_column,'\s') as word FROM some_table ) t
或得到每个单词的计数:
SELECT word,count(*) FROM ( SELECT regexp_split_to_table(some_column,'\s') as word FROM some_table ) t GROUP BY word