需要SQL输入才能获得正确的输出

需要SQL输入才能获得正确的输出,sql,null,Sql,Null,目前,没有归还任何物品。我想返回订阅者SubscriberKey(这是他们的电子邮件)、EventDate(单击发生的日期)以及他们没有单击任何内容时添加的日期(CreatedDate)。有人能帮我指出正确的方向吗?谢谢大家 试试看: Select A.SubscriberKey, A.EventDate,B.CreatedDate From _Click A JOIN _ListSubscribers B ON A.SubscriberKey = B.SubscriberKey Where B

目前,没有归还任何物品。我想返回订阅者SubscriberKey(这是他们的电子邮件)、EventDate(单击发生的日期)以及他们没有单击任何内容时添加的日期(CreatedDate)。有人能帮我指出正确的方向吗?谢谢大家

试试看:

Select A.SubscriberKey, A.EventDate,B.CreatedDate
From _Click A
JOIN _ListSubscribers B
ON A.SubscriberKey = B.SubscriberKey
Where B.ListID = '10630' AND B.CreatedDate > (Select DATEADD(day,-180,getdate())) AND A.EventDate IS NULL
Group By A.SubscriberKey,B.CreatedDate, A.EventDate

在这种情况下,我看不出组员的目的。您没有进行任何聚合

我相信这会给你想要的结果

SELECT A.SubscriberKey, A.EventDate, B.CreatedDate 
FROM _Click A, _ListSubscribers B 
WHERE A.SubscriberKey(+) = B.SubscriberKey 
AND B.ListID = '10630' 
AND B.CreatedDate > (Select DATEADD(day,-180,getdate())) 
AND nvl(A.EventDate,null) IS NULL 
GROUP BY A.SubscriberKey,B.CreatedDate, A.EventDate
以下使用外部联接的查询应给出相同的结果,并且与原始查询更为相似

select SubscriberKey,
       null as EventDate,
       CreatedDate
  from _ListSubscribers ls
 where ListID='10630'
   and CreatedDate > DateAdd( day, -180, getdate())
   and not exists( select 1 from _Click c where c.SubscriberKey = B.SubscriberKey )

是什么定义了他们没有点击任何东西?如果订阅者没有点击任何东西,那么怎么会有EventDate呢?@dbenham这就是我们想要弄清楚的。我们如何显示谁没有点击任何东西?如果他想要一个“不存在”的条件,那么他为什么要从表
a
中选择项目?还有,
groupby
it?我们需要多个组来显示他们是否单击了超过10次、2到9次、1次或根本没有单击。ANSI连接不可用于此应用程序
select ls.SubscriberKey,
       c.EventDate,
       ls.CreatedDate
  from _ListSubscribers ls
  left outer join _Click c
    on c.SubscriberKey = ls.SubscriberKey
 where ListID='10630'
   and CreatedDate > DateAdd( day, -180, getdate())
   and c.EventDate is null