I won't post the code I've got because it's far too tedious to read through, but I'll explain the situation:
I'm trying to write a report that queries customer records to see when the customer was first contacted, then provide a breakdown of whether this was within 5 working days, more than 5 working days but less than 20, or greater than 20. These breakdowns are relative to when the customer's record was first created.
The problem I'm having is that where some customers were contacted within 5 working days, but there was other contact later on in the month, my reports are picking up the same record and placing them in more than one category.
What I want is some way to represent the following query but in the correct working syntax (I'm using MySQL, BTW):
Code: Select all
SELECT DISTINCT client_id FROM communications
WHERE (
(communication_date > (client_record_added_date + INTERVAL 7 DAY))
AND
(communication_date < (client_record_added_date + INTERVAL 28 DAY))
BUT IS NOT
(communication_date < (client_record_added_date + INTERVAL 7 DAY)))Thanks,
Mecha Godzilla