Re: Simple Query Question



What column in your tables has the date value when the enquiry was created? You need that date to be able to report those that were created in the last 30 days.

Assuming that column is named enquiry_date, your query may look like:

SELECT E.enquiryID,
E.introducerID,
E.enquiry,
E.enquiry_date,
I.networkName,
I.introducerName
FROM dbo.Enquiries AS E
JOIN dbo.Introducers AS I
ON E.introducerID = I.introducerID
WHERE I.networkName = 'Network Name'
AND E.enquiry_date >= DATEADD(DAY, DATEDIFF(DAY, 0, CURRENT_TIMESTAMP) - 30, 0);

HTH,

Plamen Ratchev
http://www.SQLStudio.com

.



Relevant Pages