Scaled down table structure:
TblCustomer:
CustomerID
FirstName
Surname
etc
TblEnquiry:
EnquiryID
CustomerID
Source
etc
I am trying (as part of a larger query) to get a list of the EnquiryIDs for a customer's most recent enquiry (therefore the list will only have 1 entry for each customer along with the most recent enquiry). The tables need also INNER JOIN ON CustomerID.
In summary I am trying to do something similar to:
SELECT Customer.CustomerID, [all other customer details], [all other enquiry details]
FROM Enquiry INNER JOIN Customer ON Customer.CustomerID = Enquiry.CustomerID
WHERE EnquiryID = {Table of most recent EnquiryIDs for each customer}
ORDER BY Customer.Surname, Customer.FirstName
Any help would be massively appreciated.
TblCustomer:
CustomerID
FirstName
Surname
etc
TblEnquiry:
EnquiryID
CustomerID
Source
etc
I am trying (as part of a larger query) to get a list of the EnquiryIDs for a customer's most recent enquiry (therefore the list will only have 1 entry for each customer along with the most recent enquiry). The tables need also INNER JOIN ON CustomerID.
In summary I am trying to do something similar to:
SELECT Customer.CustomerID, [all other customer details], [all other enquiry details]
FROM Enquiry INNER JOIN Customer ON Customer.CustomerID = Enquiry.CustomerID
WHERE EnquiryID = {Table of most recent EnquiryIDs for each customer}
ORDER BY Customer.Surname, Customer.FirstName
Any help would be massively appreciated.