Z
ZenMasta
I have a query that lists all customers that have ordered from us since a
certain date.
SELECT tblContactData.ChurchName, tblAddresses.DCreated,
tblAddresses.Address1, tblAddresses.City, tblAddresses.State,
tblAddresses.Zip, tblOrderHdr.ShipAddressID, Max(tblOrderHdr.OrderDate) AS
MaxOfOrderDate, tblContactData.ContactID
FROM ((tblContactData INNER JOIN tblAddresses ON tblContactData.ContactID =
tblAddresses.aContactId) INNER JOIN tblStatus ON tblContactData.ConStatusID
= tblStatus.StatusID) INNER JOIN tblOrderHdr ON tblContactData.ContactID =
tblOrderHdr.oContactID
GROUP BY tblContactData.ChurchName, tblAddresses.DCreated,
tblAddresses.PrimaryAddress, tblAddresses.Address1, tblAddresses.City,
tblAddresses.State, tblAddresses.Zip, tblContactData.ConAddressAlert,
tblStatus.StatusID, tblOrderHdr.ShipAddressID, tblContactData.ContactID
HAVING (((tblContactData.ChurchName) Is Not Null) AND
((tblAddresses.DCreated)>#12/1/1990#) AND ((tblAddresses.PrimaryAddress)=-1)
AND ((tblAddresses.Address1) Is Not Null) AND ((tblAddresses.State) Is Not
Null) AND ((tblContactData.ConAddressAlert)=0) AND ((tblStatus.StatusID)=1)
AND ((Max(tblOrderHdr.OrderDate))>#12/31/2008#))
ORDER BY tblContactData.ChurchName;
This is great but it looks like I get duplicate customers appearing in the
list. The field I'd use to check for dupes is tblContactData.ContactID
How can I alter this query so it only shows the customer once?
certain date.
SELECT tblContactData.ChurchName, tblAddresses.DCreated,
tblAddresses.Address1, tblAddresses.City, tblAddresses.State,
tblAddresses.Zip, tblOrderHdr.ShipAddressID, Max(tblOrderHdr.OrderDate) AS
MaxOfOrderDate, tblContactData.ContactID
FROM ((tblContactData INNER JOIN tblAddresses ON tblContactData.ContactID =
tblAddresses.aContactId) INNER JOIN tblStatus ON tblContactData.ConStatusID
= tblStatus.StatusID) INNER JOIN tblOrderHdr ON tblContactData.ContactID =
tblOrderHdr.oContactID
GROUP BY tblContactData.ChurchName, tblAddresses.DCreated,
tblAddresses.PrimaryAddress, tblAddresses.Address1, tblAddresses.City,
tblAddresses.State, tblAddresses.Zip, tblContactData.ConAddressAlert,
tblStatus.StatusID, tblOrderHdr.ShipAddressID, tblContactData.ContactID
HAVING (((tblContactData.ChurchName) Is Not Null) AND
((tblAddresses.DCreated)>#12/1/1990#) AND ((tblAddresses.PrimaryAddress)=-1)
AND ((tblAddresses.Address1) Is Not Null) AND ((tblAddresses.State) Is Not
Null) AND ((tblContactData.ConAddressAlert)=0) AND ((tblStatus.StatusID)=1)
AND ((Max(tblOrderHdr.OrderDate))>#12/31/2008#))
ORDER BY tblContactData.ChurchName;
This is great but it looks like I get duplicate customers appearing in the
list. The field I'd use to check for dupes is tblContactData.ContactID
How can I alter this query so it only shows the customer once?