I have been trying to run a query that will return a count of how many times each unique word appears in a column of titles. I tried the option in THIS POST but consistently got an error message:
"Table "word_count" must be qualified with a dataset (e.g. dataset.table)."
word_count is a CTE (example below) so I am not sure what the issue is. Any help is appreciated.
WITH word_count AS (
SELECT Title,
1,
INSTR(Title, ' ', 1 )
FROM `circulation2023.top_food`
UNION ALL
SELECT Title,
end_pos + 1,
INSTR(Title, ' ', end_pos + 1 )
FROM word_count
WHERE end_pos > 0
),
words AS (
SELECT CASE end_pos
WHEN 0
THEN SUBSTR(Title, start_pos )
ELSE SUBSTR(Title, start_pos, end_pos - start_pos )
END
FROM word_count
)
SELECT word,
COUNT(*) AS frequency
FROM words
GROUP BY
word
ORDER BY
frequency desc, word;