<分区>
我想制作一份报告,告诉所有在过去 75 天左右没有接到电话的客户。我的专栏如下。
Customer# Customer_Name Phone_Number Call_Date 销售员
调用日期会提取任何和每次调用客户的日期。
这是我当前的查询。
select customer_no
,Customer_name
,Phone_number
,max(Call_Date) as Call_date
,Salesman
from salescalls
where call_date <= current_date - 75
我遇到的问题是,它正在拉动每一位客户,并使用 75 天或更长时间前他们最后一次被调用的时间。
例如,当最后一次通话日期是 6/4/14 时,它会提取号码并将通话日期列为 11/10/13。
它不应该列出过去 75 天内拜访过的客户。所以为了防止这种情况,我试图在 where 子句中这样做。
Where max(call_date) <= current_date - 75
但这只会给我一个错误:
aggregates not allowed in WHERE clause