我正在尋找一些指導,因為我正在努力為下面的小提琴創建一個腳本,該腳本將輸出一個高級結果表。
小提琴 = 
uj5u.com熱心網友回復:
您應該只按start_dateandcampaign_name和 includeDISTINCT以及CASE里面的運算式分組COUNT():
select start_date, campaign_name,
count(distinct case when status = 'Success' then userid end) as Unique_Sent,
count(distinct case when status = 'opens' then userid end) as Unique_Opened,
count(distinct case when status = 'clicked' then userid end) as Unique_Clicked,
round(100 * count(distinct case when status = 'opens' then userid end) /
count(distinct case when status = 'Success' then userid end)) as `% Opened`,
round(100 * count(distinct case when status = 'clicked' then userid end) /
count(distinct case when status = 'Success' then userid end)) as `% Clicked`
from Main
group by start_date, campaign_name;
請參閱
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/367509.html
下一篇:合并多個選擇陳述句并將它們分組
