При этом все даты этого года будут сравниваться с выручкой за прошлый год, сопоставленной с днем недели
SELECT
`Date`
,ROUND(SUM(`Sales`),2) SUmthisyear
,(SELECT ROUND(SUM(IF(`Date` = DATE(DATE_SUB(t1.`Date`, INTERVAL 1 YEAR)) + INTERVAL
IF (
WEEKDAY(t1.`Date`) != WEEKDAY(
DATE(DATE_SUB(t1.`Date`,INTERVAL 1 YEAR)) + INTERVAL 1 DAY
), 2, 1
) DAY,`Sales`,0) ),2)
FROM table1) SUmpreviousyear
FROM table1 t1
WHERE YEAR(`Date`) = YEAR(NOW())
GROUP BY `Date`
ORDER BY `Date`
CREATE TABLE table1 (
`Date` DATE,
`Sales` FLOAT
);
INSERT INTO table1
(`Date`, `Sales`)
VALUES
('2020-03-01', '45.00'),
('2020-03-01', '1.23'),
('2020-03-01', '30.00'),
('2020-03-01', '5.75'),
('2020-03-01', '25.63'),
('2020-02-29', '85.85'),
('2020-02-29', '26.23'),
('2020-02-29', '56.85'),
('2020-02-29', '8.96'),
('2020-02-29', '89.48'),
('2019-03-03', '3.50'),
('2019-03-03', '76.89'),
('2019-03-03', '1003.50'),
('2019-03-03', '1.34'),
('2019-03-02', '6.58'),
('2019-03-02', '90.48'),
('2019-03-02', '32.12'),
('2019-03-02', '45.89'),
('2019-03-02', '353.21'),
('2019-03-02', '3.71'),
('2019-03-02', '22.22'),
('2019-03-02', '353.65');
✓
✓
SELECT
`Date`
,ROUND(SUM(`Sales`),2) SUmthisyear
,(SELECT ROUND(SUM(IF(`Date` = DATE(DATE_SUB(t1.`Date`, INTERVAL 1 YEAR)) + INTERVAL
IF (
WEEKDAY(t1.`Date`) != WEEKDAY(
DATE(DATE_SUB(t1.`Date`,INTERVAL 1 YEAR)) + INTERVAL 1 DAY
), 2, 1
) DAY,`Sales`,0) ),2)
FROM table1) SUmpreviousyear
FROM table1 t1
WHERE YEAR(`Date`) = YEAR(NOW())
GROUP BY `Date`
ORDER BY `Date`
Date | SUmthisyear | SUmpreviousyear
:--------- | ----------: | --------------:
2020-02-29 | 267.37 | 907.86
2020-03-01 | 107.61 | 1085.23