How can I count the number of words in a string in Oracle?

前端 未结 4 1463
独厮守ぢ
独厮守ぢ 2020-12-11 16:49

I\'m trying to count how many words there are in a string in SQL.

Select  (\"Hello To Oracle\") from dual;

I want to show the number of wor

4条回答
  •  执念已碎
    2020-12-11 17:34

    Since you're using Oracle 11g it's even simpler-

    select regexp_count(your_column, '[^ ]+') from your_table
    

    Here is a sqlfiddle demo

提交回复
热议问题