Marketing Cloud SQL 查询计数布尔值不起作用

发布于 2025-01-17 18:27:50 字数 603 浏览 0 评论 0原文

我的客户数据库中有一个布尔字段。我想在查询工作室中查询它。

最终,我想计算有多少客户获得了新的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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

冷夜 2025-01-24 18:27:50

计数只会计算任何非零值,因此无论它们是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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文