0
我寫了下面這段代碼,我想製作的東西,看起來與此類似:Postgres的分組值在一起,而不是具有獨立價值
Days Before Stay | Number of Submits
-------------------------------------
0-9 | 11
10-19 | 14
20-29 | 3
我已創建它創建了一個語法錯誤選擇case語句
WITH sql_runner_query AS (SELECT
events_raw.properties ->> 'days_before_stay' AS "Number of Days
Before Stay",
COUNT(CASE WHEN ((events_raw.properties ->> 'event_type') LIKE
'fs_mystay_activity_submit') THEN 1 ELSE NULL END) AS "Number of
Activities Processed"
FROM events_raw
WHERE (events_raw.account_id = 7270737) AND
((((events_raw.properties ->> 'days_before_stay') IS NOT NULL) AND
((events_raw.properties ->> 'days_before_stay') IS NOT NULL AND
LENGTH(events_raw.properties ->> 'days_before_stay') <> 0))) AND
(events_raw.account_id > 0)
GROUP BY 1
ORDER BY 1 desc
LIMIT 500
)
(SELECT
events_raw.properties ->> 'days_before_stay' AS "Number of Days
Before Stay",
COUNT(CASE WHEN ((events_raw.properties ->> 'event_type') LIKE
'fs_mystay_activity_submit') THEN 1 ELSE NULL END) AS "Number of
Activities Processed"
case when 'days_before_stay' >= 0 and <=10 then '0-10'
else
'11-300' end as range
FROM events_raw
GROUP BY 1,2
ORDER BY 1 DESC
LIMIT 5000
您需要分享錯誤消息,並解釋它與問題標題的關係。另外,CTE sql_runner_query在主查詢中根本沒有被請求。 – FuzzyChef