@r937@DaveMaxwell
Hi can I ask some help how can I query records from previous week. ?
example if I have customer that will pay every Monday, how can I make the query to check the transaction from tuesday to sunday of the previous week ?
How can I filter on this to execute only if the CURRENT_DATE is equal to dateofpayment of customer,
example if today is “Monday” then I will get all transaction records of customers whose dateofpayment is monday.
customer_table
id custname dateofpayment
24 John Monday
25 Lisa Tuesday
26 Marissa Friday
27 Eric Monday
SELECT c.id
, c.custname
, t.transid
, t.trans_date
FROM customers AS c
INNER
JOIN transactions AS t
ON t.cust_id = c.id
AND t.trans_date BETWEEN CURRENT_DATE - INTERVAL 6 DAY
AND CURRENT_DATE
WHERE c.dateofpayment = DAYNAME(CURRENT_DATE)