I have to perform a query that return the reverse cumulative sum with every stage that the client has passed, jumping the two firsts.
The database register every customer that have been discarded and the stage that it happen.
This is my sample data:
CREATE TABLE descartados
(`stage` varchar(15), `date` datetime);
INSERT INTO descartados
(`stage`, `date`)
VALUES
('Entrada', '2021-01-18 13:03:36'),
('Filtro 2', '2021-01-11 19:40:47'),
('Filtro 2', '2021-01-11 13:28:54'),
('Filtro 2', '2021-01-11 19:44:16'),
('Entrada', '2021-01-11 13:28:24'),
('Entrada', '2021-01-11 13:29:28'),
('Entrada', '2021-01-11 18:17:26'),
('Filtro 2', '2021-01-11 19:40:22'),
('Entrada', '2021-01-11 18:35:32'),
('Filtro 2', '2021-01-11 18:40:27'),
('Entrada', '2021-01-12 17:49:03'),
('Filtro 2', '2021-01-12 17:19:15'),
('Entrada', '2021-01-12 12:37:41'),
('Entrada', '2021-01-12 18:17:38'),
('Entrada', '2021-01-13 12:12:27'),
('Entrada', '2021-01-13 12:13:00'),
('Entrada', '2021-01-12 19:00:05'),
('Filtro 1', '2021-01-18 12:48:21'),
('Entrada', '2021-01-12 17:52:18'),
('Entrada', '2021-01-13 12:13:53'),
('Entrada', '2021-01-13 12:43:28'),
('Entrada', '2021-01-13 13:13:11'),
('Entrada', '2021-01-13 13:15:13'),
('Agendados', '2021-01-13 13:15:13'),
('Qualificados', '2021-01-13 13:15:13'),
('Agendados', '2021-01-13 13:15:13'),
('Qualificados', '2021-01-13 13:15:13'),
('Agendados', '2021-01-13 13:15:13');
SELECT descartados.stage, descartados.date FROM descartados;