+1  A: 

There are several ways to do this. But I think you're close. You don't seem to have the date range correct for 3-6 months in your primary query. You were checking for anything from 6 months until now. That doesn't match the spec of the OP - users of an event 3-6 months ago, but not within the last 3 months. Logically it seems the same, but try this.

SELECT DISTINCT e.id, e.insertion_date, c.name
FROM event e
JOIN client c ON c.id = e.clientFK
WHERE e.clientFK NOT IN (
  SELECT e.clientFK FROM event e
  WHERE e.insertion_date > (NOW() - INTERVAL 3 MONTH)
)
AND e.insertion_date BETWEEN (NOW() - INTERVAL 3 MONTH) AND (NOW() - INTERVAL 6 MONTH)
AND e.officeFK = 1
ORDER BY e.insertion_date DESC
Jason McCreary
You are correct on my out date range. I've corrected that, but I'm still returning 0 rows. See the update I made to the original post above.
Chris Shelton
Thanks for your help so far!!!
Chris Shelton
I've updated my code. Break the query into parts and check the output. That is run the sub-query only and see what it finds. I've also dropped the `LEFT JOIN` to just `JOIN`.
Jason McCreary
Thanks Jason...you put me on the right track. Apparently the insertion_date didn't like the 'BETWEEN' operator. I switched it to < > and it worked perfect. I've update my code above. Again, thanks a lot for the help. I really appreciate it!
Chris Shelton
Interesting. What is the columns data type out of curiosity?
Jason McCreary
Datetime - Do you think that might be the issue? I use these columns with BETWEEN in other queries throughout the site, but for whatever reason they wouldn't work here.
Chris Shelton