# SQL：每个用户最常用的N个词（用他们的语言交流！）

**URL:** <https://meta.discourse.org/t/sql-the-most-n-used-words-per-user-speak-their-language/38556>\
**Category:** Data & reporting\
**Tags:** sql-query\
**Created:** [2016年一月27日 05:55 UTC](https://meta.discourse.org/t/sql-the-most-n-used-words-per-user-speak-their-language/38556 "2016-01-27T05:55:21Z")\
**Posts on this page:** 1\
**Showing post:** 21

<div class="post-metadata">

**Author:** ![DiscourseMetrics](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/discoursemetrics/32/55756_2.png) [@DiscourseMetrics](https://meta.discourse.org/u/DiscourseMetrics)\
**Post date:** [2019年五月17日 21:47 UTC](https://meta.discourse.org/t/sql-the-most-n-used-words-per-user-speak-their-language/38556/21 "2019-05-17T21:47:32Z")

</div>

To answer myself, this seems to work decently:

```
SELECT word, count(*)
FROM ( 
  SELECT regexp_split_to_table(raw, ' ') as word
  FROM posts
  order by id desc
  limit 100000
) t
GROUP BY word
order by count(*) desc

```

---

_[View the full topic](https://meta.discourse.org/t/sql-the-most-n-used-words-per-user-speak-their-language/38556)._
