-1

I'm using a SQL database. In this database, in a column, i put a lot of different string.

I would like to find the most occuring word in the string in the column.

For exemple if i had 3 strings : "Hello you" "Hello, How are you ?" "Fine and you ?"

I would like SQL request return me : You then Hello etc etc...

Thank you for helping.

Thibaud

Thibaud
  • 77
  • 1
  • 8
  • 1
    (1) Tag your question with the database you are using. (2) This is not an easy thing to do in a SQL database (less difficult in some databases than others). – Gordon Linoff Oct 05 '17 at 19:21
  • Welcome to SO. This site is not a code-writing service and is not meant for delivering complete solutions. Users are expected to show some effort and code whilst SO is here to help you solve specific programming problems along the way. Have you tried anything already? Please read: https://stackoverflow.com/help/asking – Maciej Jureczko Oct 05 '17 at 20:00

1 Answers1

0
SELECT word, count(*) AS ct
FROM   tbl, unnest(string_to_array(message, ' ')) word  -- implicit LATERAL join
GROUP  BY 1
ORDER  BY 2 DESC
A.Kot
  • 7,615
  • 2
  • 22
  • 24