Query to count words SQLite 3
The previous answer is incorrect for columns that are blank. You will need to add a case/when/then statement to your select:
SELECT someStr, CASE WHEN length(someStr) >= 1 THEN (length(someStr) - length(replace(someStr), ' ', '')) + 1 ELSE (length(someStr) - length(replace(someStr), ' ', '')) END as NumOfWordsFROM someTable;
Edited: If the column has 0 spaces, but had a word in it, it would incorrectly report 0. Changed the condition to allow for it.
The answer from @Ziferius has a small syntax error, the following one is a working one, tested by myself.
SELECT someStr, CASE WHEN length(someStr) >= 1 THEN (length(someStr) - length(replace(someStr, ' ', ''))) + 1 ELSE (length(someStr) - length(replace(someStr, ' ', ''))) END as NumOfWords FROM someTable;