Postgres中字符串的词频? [英] Word frequencies from strings in Postgres?
本文介绍了Postgres中字符串的词频?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以从Postgres中包含文本字符串的字段中识别出不同的单词和每个单词的计数?
Is it possible to identify distinct words and a count for each, from fields containing text strings in Postgres?
推荐答案
像这样吗?
SELECT some_pk,
regexp_split_to_table(some_column, '\s') as word
FROM some_table
然后轻松地获得不同的单词:
Getting the distinct words is easy then:
SELECT DISTINCT word
FROM (
SELECT regexp_split_to_table(some_column, '\s') as word
FROM some_table
) t
或获取每个单词的计数:
or getting the count for each word:
SELECT word, count(*)
FROM (
SELECT regexp_split_to_table(some_column, '\s') as word
FROM some_table
) t
GROUP BY word
这篇关于Postgres中字符串的词频?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文