如何区分没有ID的日志以分别在SQL上进行汇总?

我有一个(假设的)设备来记录其电池的消耗事件。它有几个插槽,并且每天记录每个插槽中电池消耗的百分比。数据如下所示:

CREATE TABLE batteries
(slot integer, day date, percentage integer);

INSERT INTO batteries
(slot, day, percentage)
VALUES
(0, '2020-05-08', 96),
(0, '2020-05-09', 96),
(0, '2020-05-10', 97),
(0, '2020-05-11', 97),
(0, '2020-05-12', 97),
(0, '2020-05-13', null),
(0, '2020-05-14', 95),
(0, '2020-05-15', 96),
(0, '2020-05-16', null),
(0, '2020-05-17', 1),
(0, '2020-05-18', 2),
(1, '2020-05-08', 10),
(1, '2020-05-09', 10),
(1, '2020-05-10', 10);

The log shows that in slot 0, a battery that was almost completely consumed has been replaced on May 13 by another used battery, which was then replaced on May 16 by a new one. The battery in slot 1 always reported 10% usage.

我需要确定每个电池,报告的最后一个值以及报告该值的第一个和最后一个日期。所以这是我想要得到的输出:

slot  min_date      max_date      percentage  sequence
------------------------------------------------------
0     '2020-05-10'  '2020-05-12'  97          0
0     '2020-05-15'  '2020-05-15'  96          1
0     '2020-05-18'  '2020-05-18'  2           2
1     '2020-05-08'  '2020-05-10'  10          0

Last known value of battery 0 in slot 0 was 97, which it reported from May 10 to May 12;

Last known value of battery 1 in slot 0 was 96, which it reported only on May 15;

Last known value of battery 2 (current) in slot 0 was 2, which it reported only on May 18;

Last known value of battery 0 (current) in slot 1 was 10, which it reported from May 08 to May 10.

My main issue here is how to get the min and max date for each battery without having a battery id. In this example, if I group by slot and percentage to get the dates, I'll get the wrong min date on battery 1 of slot 0, because there was another battery with the same percentage in that slot before.

有没有一种方法可以在不进行后处理的情况下通过SQL查询获得此结果?