How do I find all records 7 days before a field in an SQL database?
I need to find all transaction dates that were placed 7 days before the pickup date of the same record.
I am currently using SequelPro so that my have an effect on available syntaxes.
This is currently my table that I am pulling the records from.
This is the exact question I am being asked;
Write a query to display all details of transactions that were made at least one week before the pickup date.
Advertisement
Answer
Isn’t it straightforward?
SELECT * FROM TransactionTable WHERE DATEDIFF(pickupdate, transactiondate) >= 7;