如果值存在,则获取记录总和,将其视为 1,而不是精确值
P粉289775043
P粉289775043 2024-04-04 16:49:24
0
1
441

我需要“打开”为 2 并单击为 1 但现在我越来越喜欢打开为 5 并单击为 2

"SELECT 
COALESCE(sum(requested),0) as requested,
COALESCE(sum(processed),0) as processed,
COALESCE(sum(open),0) as open,
COALESCE(sum(click),0) as click,
COALESCE(sum(dropped),0) as dropped,
COALESCE(sum(delivered),0) as delivered,
COALESCE(sum(spamreport),0) as spamreport,
COALESCE(sum(deferred),0) as deferred,
COALESCE(sum(bounce),0) as bounce,
COALESCE(sum(unsubscribe),0) as unsubscribe
FROM CAMPAIGN_REPORTS WHERE _kftCampaingID='".$campaignId."'"

P粉289775043
P粉289775043

全部回复(1)
P粉883223328

sum() 按预期工作。如果您希望将 0 以上的任何值视为 1,请编写如下 if 条件。话虽如此,coalesce 在这里看起来是多余的。

sum(if(open is not null and open > 0, 1, 0)),
sum(if(click is not null and click > 0, 1, 0))
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板