эй, у меня есть эти таблицы и данные:
create table CUSTOMER(CustNum INT, CustTell INT, CustFname VARCHAR(15), CustLname VARCHAR(15), CustCounty VARCHAR(20),
CustTown VARCHAR(20), CustStreet VARCHAR(20), CustPostCode CHAR(7), CustDob DATE, CustEmail VARCHAR(45), Branch VARCHAR(25), PRIMARY KEY(CustNum, CustTell));
create table PURCHASE(TDate DATE, TTime TIME, BramchAddr VARCHAR(25), TillNo INT, CustNo INT, AssistantNo INT, ProdCode INT, Qty INT, BranchAddr VARCHAR(25), PRIMARY KEY(TDate, TTime));
INSERT INTO CUSTOMER (CustNum, CustTell, CustFname, CustLname, CustCounty, CustTown, CustStreet, CustPostcode, CustDob, CustEmail, Branch) VALUES
(436196, 0763126847, "John", "Murphy", "West Yorkshire", "Leeds", "Calverley Str" ,"LS1 1AZ", '2000-03-24', "John14@gmail.com", "London"),
(538912, 0723749154, "Isla", "Taylor", "Leicestershire", "Leicester", "Nedham Str" ,"LE1 1AF", '1996-11-02', "Island@gmail.com", "Brighton"),
(368549, 0796871325, "Charlie", "Byrne", "Greater London", "London", "Peel Str" ,"E1 6AN", '1976-12-17', NULL, "Southampton"),
(377461, 0731895518, "William", "Evans", "Telford and Wrekin", "Telford", "Peel Str" ,"TF1 1AF", '1978-08-21', "Will12@mail.com", "Surrey"),
(652387, 0778234657, "Thomas", "Li", "Merseyside", "Liverpool", "Dumbrees Str" ,"L1 0AH", '1999-01-00', "Tom65@hotmail.com", "Lancaster"),
(543234, 0723432133, "Alex", "Michael", "West Yorkshire", "Leeds", "Richmond Green Str", "LS1 1HE", '1997-06-28', "Alehfds@gmail.com", "London");
INSERT INTO PURCHASE (TillNo, TDate, TTime, CustNo, AssistantNo, ProdCode, Qty, BranchAddr) VALUES
(005, '2020-03-10', '19:12:55', 368549, 48964, 3645789, 3, "Southampton"),
(005, '2020-03-10', '19:32:23', 368549, 48964, 6875436, 1, "Southampton"),
(005, '2020-03-10', '19:42:55', 368549, 48964, 8681466, 1, "Southampton"),
(005, '2020-03-11', '15:48:05', 652387, 48964, 3629191, 2, "Southampton"),
(006, '2020-03-10', '11:43:23', 436196, 18537, 3645789, 3, "Southampton"),
(004, '2020-03-10', '11:49:34', 436196, 56485, 2528726, 1, "Southampton"),
(001, '2020-02-25', '14:22:48', 377461, 23485, 6875436, 2, "Southampton"),
(001, '2020-02-25', '14:52:48', 377461, 23485, 1651687, 2, "London"),
(001, '2020-01-15', '18:18:56', 538912, 23485, 1651687, 1, "London"),
(006, '2020-01-15', '18:45:56', 538912, 18537, 8658458, 1, "London"),
(002, '2020-01-12', '09:32:14', 652387, 15615, 3697260, 3, "London"),
(003, '2019-05-26', '11:20:43', 368549, 83157, 4494292, 8, "Lancaster"),
(001, '2021-03-16', '13:43:40', 368549, 23485, 3697260, 6, "Southampton"),
(005, '2019-05-19', '17:40:16', 538912, 48964, 8005597, 5,"London"),
(005, '2019-11-27', '01:48:18', 538912, 48964, 5600196, 1, "Brighton"),
(006, '2020-12-06', '18:21:36', 538912, 18537, 6889045, 2, "Lancaster"),
(003, '2020-03-10', '08:09:05', 377461, 83157, 1076404, 7, "Lancaster"),
(005, '2020-07-24', '14:58:47', 538912, 48964, 4494292, 2, "Lancaster"),
(004, '2020-10-17', '19:19:32', 368549, 56485, 1651687, 2, "Southampton"),
(005, '2019-05-20', '22:19:57', 652387, 48964, 8681466, 6, "Southampton"),
(006, '2020-10-12', '00:50:32', 368549, 18537, 9346249, 7, "London"),
(001, '2020-11-04', '22:08:54', 377461, 23485, 8681466, 6, "Brighton");
И я хочу сделать запрос, в котором будет показано, какие учетные записи клиентов не были активными в течение последнего месяца. Это то, что я пытался, но не смог:
SELECT PURCHASE.CustNo, PURCHASE.TDate, CUSTOMER.CustNum FROM (CUSTOMER
LEFT JOIN PURCHASE ON CUSTOMER.CustNum = PURCHASE.CustNo)
WHERE PURCHASE.TDate = CURDATE() - INTERVAL 1 MONTH
ORDER BY PURCHASE.CustNo;
Если я могу изменить даты, есть ли способ сделать такой запрос?
Желаемым результатом будет все данные клиентов, которые не были активны в течение последнего месяца.