List:General Discussion« Previous MessageNext Message »
From:Brian Dunning Date:November 3 2009 8:54pm
Subject:Re: Customers with no recent orders?
View as plain text  
More info. If the tables look like this:

customers
------------------
cust_id
signup_date

orders
------------------
order_id
cust_id
order_date

Then the SQL needs to accomplish something like this:

select * from customers
left join orders on customers.cust_id = orders.cust_id
where signup_date < now() - interval 14 day
and sum(if(order_date > now() - interval 14 day, 1, 0)) = 0

But that gives me "Invalid use of group function".
Thread
Customers with no recent orders?Brian Dunning3 Nov
  • Re: Customers with no recent orders?Brian Dunning3 Nov
    • RE: Customers with no recent orders?Martin Gainty3 Nov
      • Re: Customers with no recent orders?Brian Dunning3 Nov