Marketing Cloud SQL 查询计数布尔值不起作用
我的客户数据库中有一个布尔字段。我想在查询工作室中查询它。
最终,我想计算有多少客户获得了新的T& CS,以及有多少客户不使用产品。
为此,我写了...
, COUNT(CASE WHEN X_customer = 1 THEN 1 ELSE 0 END) AS X_Customer_Count
, COUNT(CASE WHEN Y_customer = 0 THEN 1 ELSE 0 END) AS Y_Customer_Count
或
, COUNT(CASE WHEN X_customer = 'True' THEN 1 ELSE 0 END) AS X_Customer_Count
, COUNT(CASE WHEN Y_customer = 'False' THEN 1 ELSE 0 END) AS Y_Customer_Count
X Customer =已签署了T& c new
y Customer =已签署了T& c Old的
作品,并给我一些结果。我看不到错误。但是两列中的结果完全相同。为什么?它只能计算为真或错误。
帮助? :)
i've got a boolean field within our customer database. i want to query it in query studio.
I want to count in the end how many customers got the new T&Cs and how many not by product.
for that i wrote...
, COUNT(CASE WHEN X_customer = 1 THEN 1 ELSE 0 END) AS X_Customer_Count
, COUNT(CASE WHEN Y_customer = 0 THEN 1 ELSE 0 END) AS Y_Customer_Count
or
, COUNT(CASE WHEN X_customer = 'True' THEN 1 ELSE 0 END) AS X_Customer_Count
, COUNT(CASE WHEN Y_customer = 'False' THEN 1 ELSE 0 END) AS Y_Customer_Count
X customer = has signed T&C New
Y customer = has signed T&C Old
Both works and give me some result. I dont see an error. BUT the result within both columns is exactly the same. Why? It should only count if its either true or false.
Help? :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
计数只会计算任何非零值,因此无论它们是1还是0,都会计算这些值。尝试使用总和
COUNT will just count any non-null value, so it will count those values whether they are 1 or 0. Try using SUM instead