АА
with tr as ( select 'привет как дела' as col union select 'все отлично спасибо как сам'),
tr_spl as (select regexp_split_to_array(col,' ') col_spl from tr ),
tr_unnst as (select unnest(col_spl) as col_unst from tr_spl)
select col_unst, count(*)
from tr_unnst
group by col_unst
order by count(*) desc;
result:
col_unst | count
----------+-------
как | 2
все | 1
сам | 1
дела | 1
отлично | 1
спасибо | 1
привет | 1