簡體   English   中英

用 case 語句聚合 function

[英]Aggregate function with case statement

我正在嘗試將聚合 function 與 CASE 語句一起使用,但語法不正確。
我附上了示例代碼,並附上了關於我想要實現的目標的問題,但我收到了語法錯誤。

count(case when weekminus1 = 0 and week0 = 1 then distinct(asin) end) as asin_added,
count(case when weekminus1 = 0 and week0 = 1 then distinct(fnsku) end) as fnsku_added,

任何線索都會有所幫助。

你想表達為:

count(distinct case when weekminus1 = 0 and week0 = 1 then asin end) as asin_added,
count(distinct case when weekminus1 = 0 and week0 = 1 thenfnsku end) as fnsku_added,

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM