R
rdleigh
Guest
Hello,
I need to track new customers by the first visit to our facility, and by the type of trigger ( that is to say, there is a Reference field within the database containing 24 different triggers, to coina phrase, such as by brochure, referral, drive-by, Yellow Pages, etc.).
I have tried the following SQL query statements (two different tables created) but find that it not only does not eliminate subsequent date visits, but does not correctly report the very first visit of that customer within (example) 2001 if the customer actually has a prior history with us.
*********
1st Time Customer Query GV 2001 : Make Table Query (creates 1st Time Client Table)
SELECT DISTINCTROW Customers.lastname, Customers.firstname, Customers.address, Customers.city, Customers.state, Customers.zip, First(Payments.PayDate) AS FirstofPayDate, Payments.PayAmt, LEADSOURCE.longcode, LEADSOURCE.datacode, LEADSOURCE.datastring INTO [1st TIME CLIENT TABLE]
FROM ((Customers INNER JOIN Payments ON Customers.cust_ID = Payments.cust_ID) INNER JOIN Market ON Customers.cust_ID = Market.cust_ID) INNER JOIN LEADSOURCE ON Market.Ref1 = LEADSOURCE.longcode
GROUP BY Customers.lastname, Customers.firstname, Customers.address, Customers.city, Customers.state, Customers.zip, LEADSOURCE.longcode, LEADSOURCE.datacode, LEADSOURCE.datastring, Payments.PayAmt
HAVING (((First(Payments.PayDate)) Between [Enter FROM Date] And [Enter TO Date]))
ORDER BY Customer.lastname;
PROBLEM – THIS CREATES DUPLICATES, I.E., ALL VISITS BY THAT CUSTOMER DURING THAT YEAR SHOW UP…AND IF CUSTOMER HAD PRIOR HISTORY, HE SHOULD NOT BE REPORTED IN THIS QUERY/TABLE.
*********************************************
GLENVIEW NEW CLIENT 2001 QUERY MT : Make Table Query (creates GLENVIEW NEW CLIENTS 2001 table)
SELECT DISTINCTROW Customers.lastname, Customers.firstname, Customers.address, Customers.city, Customers.state, Customers.zip, First(Payments.PayDate) AS FirstofPayDate INTO [GLENVIEW NEW CLIENTS 2001]
FROM Customers INNER JOIN Payments ON Customers.cust_ID = Payments.cust_ID
GROUP BY Customers.lastname, Customers.firstname, Customers.address, Customers.city, Customers.state, Customers.zip
HAVING (((First(Payments.PayDate)) Between [enter FROM date] And [enter TO date]))
ORDER BY Customers.lastname, Customers.zip;
Can someone explain how to find the very first occurrence (visit) of a customer (in this case, for 2001 in a database that goes back to 1995 and has tens of thousands of records,) then reports the source of that client (trigger) and the sales volume so generated?
The goal is to make informed decisions on our marketing and advertising programs. Thank you for your help.
I need to track new customers by the first visit to our facility, and by the type of trigger ( that is to say, there is a Reference field within the database containing 24 different triggers, to coina phrase, such as by brochure, referral, drive-by, Yellow Pages, etc.).
I have tried the following SQL query statements (two different tables created) but find that it not only does not eliminate subsequent date visits, but does not correctly report the very first visit of that customer within (example) 2001 if the customer actually has a prior history with us.
*********
1st Time Customer Query GV 2001 : Make Table Query (creates 1st Time Client Table)
SELECT DISTINCTROW Customers.lastname, Customers.firstname, Customers.address, Customers.city, Customers.state, Customers.zip, First(Payments.PayDate) AS FirstofPayDate, Payments.PayAmt, LEADSOURCE.longcode, LEADSOURCE.datacode, LEADSOURCE.datastring INTO [1st TIME CLIENT TABLE]
FROM ((Customers INNER JOIN Payments ON Customers.cust_ID = Payments.cust_ID) INNER JOIN Market ON Customers.cust_ID = Market.cust_ID) INNER JOIN LEADSOURCE ON Market.Ref1 = LEADSOURCE.longcode
GROUP BY Customers.lastname, Customers.firstname, Customers.address, Customers.city, Customers.state, Customers.zip, LEADSOURCE.longcode, LEADSOURCE.datacode, LEADSOURCE.datastring, Payments.PayAmt
HAVING (((First(Payments.PayDate)) Between [Enter FROM Date] And [Enter TO Date]))
ORDER BY Customer.lastname;
PROBLEM – THIS CREATES DUPLICATES, I.E., ALL VISITS BY THAT CUSTOMER DURING THAT YEAR SHOW UP…AND IF CUSTOMER HAD PRIOR HISTORY, HE SHOULD NOT BE REPORTED IN THIS QUERY/TABLE.
*********************************************
GLENVIEW NEW CLIENT 2001 QUERY MT : Make Table Query (creates GLENVIEW NEW CLIENTS 2001 table)
SELECT DISTINCTROW Customers.lastname, Customers.firstname, Customers.address, Customers.city, Customers.state, Customers.zip, First(Payments.PayDate) AS FirstofPayDate INTO [GLENVIEW NEW CLIENTS 2001]
FROM Customers INNER JOIN Payments ON Customers.cust_ID = Payments.cust_ID
GROUP BY Customers.lastname, Customers.firstname, Customers.address, Customers.city, Customers.state, Customers.zip
HAVING (((First(Payments.PayDate)) Between [enter FROM date] And [enter TO date]))
ORDER BY Customers.lastname, Customers.zip;
Can someone explain how to find the very first occurrence (visit) of a customer (in this case, for 2001 in a database that goes back to 1995 and has tens of thousands of records,) then reports the source of that client (trigger) and the sales volume so generated?
The goal is to make informed decisions on our marketing and advertising programs. Thank you for your help.