|
with recursive cte as (
select
substring(concat(sent, ' '), 1, locate(' ', sent)) word,
substring(concat(sent, ' '), locate(' ', sent) + 1) sent
from messages
union all
select
substring(sent, 1, locate(' ', sent)) word,
substring(sent, locate(' ', sent) + 1) sent
from cte
where locate(' ', sent) > 0
)
select row_number() over(order by count(*) desc, word) wid, word, count(*) freq
from cte
group by word
order by wid
wid |
word |
freq |
1 |
alex |
3 |
2 |
alin |
2 |
3 |
hello |
2 |
4 |
is |
2 |
5 |
my |
2 |
6 |
name |
2 |
7 |
and |
1 |
8 |
hey |
1 |
9 |
I'm |
1 |
10 |
tom |
1 |
… |
|