我想寫一個查詢來在每個@字符後面分割一列。然後我希望能夠在每個細分市場中對這些進行計數。如何在配置單元中合併拆分和計數
我已成功地編寫以下查詢在蜂巢:
SELECT
distinct split (msg_txt,'\\@')[0] AS first_msg, count(*)
FROM table1
;
但這不會讓我通過,以獲得計數添加組。我試圖用一個子查詢這樣做:
SELECT first_msg, count(*)
FROM (
SELECT
distinct split (msg_txt,'\\@')[0] AS first_msg
FROM table1
)
GROUP BY first_msg
;
,但是這給了我以下錯誤:
Error while compiling statement: FAILED: ParseException line 7:6 missing EOF at 'BY' near 'GROUP'
所以不知道我怎麼能寫這個查詢。
如果有人可以請建議真的很感激。
在此先感謝。
我不知道爲什麼會得出一個downvote,答案是正確的。 –