我正在尝试编写一个查询,说明iff在all1o1s
和SC.salesforce_id
中存在ID,然后将它存在于all1o1s
中的次数求和。
我写:
select
sc.salesforce_id,
sum(case when all1o1s.member_id = sc.salesforce_id then 1 else 0) as "1o1 completed count"
from salesforce_contacts as sc
inner join leenk_1o1s as all1o1s on sc.salesforce_id = all1o1s.member_id
group by sc.salesforce_id;
我在总和线上得到一个错误。如何构建此查询?
谢谢!
试试这个
select b.salesforce_id,count(1) from all1o1s a,salesforce_contacts b where a.id=b.salesforce_id
group by b.salesforce_id having count(1) > 1
根据你的问题,你需要数不算