0
如何選擇字中空格分隔的列中最常用的字?我使用SQLite作爲數據庫。選擇子字符串以空格分隔的列中計數最高的子字符串
例如,
Column1 Column2
1 Apple Orange Banana
2 Strawberry Apple Pineapple
3 Grape Mango
所需的輸出:蘋果
如何選擇字中空格分隔的列中最常用的字?我使用SQLite作爲數據庫。選擇子字符串以空格分隔的列中計數最高的子字符串
例如,
Column1 Column2
1 Apple Orange Banana
2 Strawberry Apple Pineapple
3 Grape Mango
所需的輸出:蘋果
字計數。假設你的表被稱爲yourTable。使用公用表表達式(with clause)將Column2拆分爲單獨的單詞。我借了一些知識,從user1461607以及與此想出了:。
WITH RECURSIVE split(word, str, hasspace) AS (
SELECT '', Column2, 1 from yourTable
UNION ALL SELECT
substr(str, 0,
case when instr(str, ' ')
then instr(str, ' ')
else length(str)+1 end),
ltrim(substr(str, instr(str, ' ')), ' '),
instr(str, ' ')
FROM split
WHERE hasspace
)
SELECT trim(word) FROM split WHERE word!='' GROUP BY trim(word) ORDER BY count(*) DESC LIMIT 1
這完美的作品,忽視了「無法分析查詢文本」查詢生成器警告感謝,但,Visual Studio的查詢構建器不斷重新安排查詢時我再次打開它的查詢生成器,但我始終可以將原始查詢粘貼到查詢生成器中,如果有人知道如何防止這種情況發生,那麼我會很感激你如何發佈。 – Dog