By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE xxx_xxxx_xxxx (
`date` VARCHAR(10),
`ant` INTEGER,
`num_room` INTEGER,
`cumulative_room` INTEGER
);
INSERT INTO xxx_xxxx_xxxx
(`date`, `ant`, `num_room`, `cumulative_room`)
VALUES
('28-04-2020', '6', '1', '1'),
('28-04-2020', '3', '1', '2'),
('28-04-2020', '4', '1', '3'),
('28-04-2020', '7', '1', '4'),
('28-04-2020', '4', '1', '5');
Records: 5 Duplicates: 0 Warnings: 0
SELECT
t1.*
,t2.max_room - `cumulative_room` 'reverse_cumulative room'
FROm xxx_xxxx_xxxx t1
INNER JOIN (SELECT MAX(`cumulative_room`) +1 max_room, `date` FROM xxx_xxxx_xxxx GROUP BY `date`) t2
ON t1.`date` = t2.`date`;
date | ant | num_room | cumulative_room | reverse_cumulative room |
---|---|---|---|---|
28-04-2020 | 6 | 1 | 1 | 5 |
28-04-2020 | 3 | 1 | 2 | 4 |
28-04-2020 | 4 | 1 | 3 | 3 |
28-04-2020 | 7 | 1 | 4 | 2 |
28-04-2020 | 4 | 1 | 5 | 1 |