add batch remove batch split batch comment selection show hidden batches hide batch highlight batch
db<>fiddle
donate feedback about
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
create or replace SEQUENCE seqMetric START WITH 1 INCREMENT BY 1;
CREATE TABLE pv_metrics (id int default(10000- nextval(seqMetric)) -- auto_increment
, primary key(id)
,created_at datetime, verbrauch_ges float );

INSERT INTO pv_metrics (created_at, verbrauch_ges) VALUES
('2025-03-23 00:00:04', 5628.79)
,('2025-03-22 00:00:06', 5622.54)
,('2025-03-21 00:00:11', 5615.44)
,('2025-03-20 00:00:13', 5609.49)
,('2025-03-19 00:00:17', 5605.4)
,('2025-03-18 00:00:00', 5600.45)
,('2025-03-17 00:00:03', 5591.36)
,('2025-03-16 00:00:09', 5585.2)
,('2025-03-15 00:00:16', 5578.96)
,('2025-03-14 00:00:04', 5571.1)
,('2025-03-13 00:00:07', 5560.34)
,('2025-03-12 00:00:10', 5550.54)
,('2025-03-11 00:00:13', 5540.12)
,('2025-03-10 00:00:16', 5534.81)
,('2025-03-09 00:00:18', 5528.48)
,('2025-03-08 00:00:17', 5521.71)
,('2025-03-07 00:00:11', 5515.27)
,('2025-03-06 00:00:14', 5510.17)
,('2025-03-05 00:00:06', 5504.08)
,('2025-03-04 00:00:09', 5497.21);
select * from pv_metrics;
Records: 20  Duplicates: 0  Warnings: 0
id created_at verbrauch_ges
9980 2025-03-04 00:00:09 5497.21
9981 2025-03-05 00:00:06 5504.08
9982 2025-03-06 00:00:14 5510.17
9983 2025-03-07 00:00:11 5515.27
9984 2025-03-08 00:00:17 5521.71
9985 2025-03-09 00:00:18 5528.48
9986 2025-03-10 00:00:16 5534.81
9987 2025-03-11 00:00:13 5540.12
9988 2025-03-12 00:00:10 5550.54
9989 2025-03-13 00:00:07 5560.34
9990 2025-03-14 00:00:04 5571.1
9991 2025-03-15 00:00:16 5578.96
9992 2025-03-16 00:00:09 5585.2
9993 2025-03-17 00:00:03 5591.36
9994 2025-03-18 00:00:00 5600.45
9995 2025-03-19 00:00:17 5605.4
9996 2025-03-20 00:00:13 5609.49
9997 2025-03-21 00:00:11 5615.44
9998 2025-03-22 00:00:06 5622.54
9999 2025-03-23 00:00:04 5628.79
SELECT created_at, verbrauch_ges
,lag(verbrauch_ges)over(order by created_at) prev_verbauch_ges
FROM (
select min(id) id
from pv_metrics
group by DATE(created_at)
ORDER BY min(id) DESC limit 20
) s
inner join pv_metrics m on m.id=s.id
ORDER BY s.ID DESC ;
created_at verbrauch_ges prev_verbauch_ges
2025-03-23 00:00:04 5628.79 5622.54
2025-03-22 00:00:06 5622.54 5615.44
2025-03-21 00:00:11 5615.44 5609.49
2025-03-20 00:00:13 5609.49 5605.4
2025-03-19 00:00:17 5605.4 5600.45
2025-03-18 00:00:00 5600.45 5591.36
2025-03-17 00:00:03 5591.36 5585.2
2025-03-16 00:00:09 5585.2 5578.96
2025-03-15 00:00:16 5578.96 5571.1
2025-03-14 00:00:04 5571.1 5560.34
2025-03-13 00:00:07 5560.34 5550.54
2025-03-12 00:00:10 5550.54 5540.12
2025-03-11 00:00:13 5540.12 5534.81
2025-03-10 00:00:16 5534.81 5528.48
2025-03-09 00:00:18 5528.48 5521.71
2025-03-08 00:00:17 5521.71 5515.27
2025-03-07 00:00:11 5515.27 5510.17
2025-03-06 00:00:14 5510.17 5504.08
2025-03-05 00:00:06 5504.08 5497.21
2025-03-04 00:00:09 5497.21 null
SELECT m.created_at, verbrauch_ges
,lag(verbrauch_ges)over(order by created_at) prev_verbauch_ges
FROM (
select min(created_at) created_at
from pv_metrics
group by DATE(created_at)
ORDER BY min(id) DESC limit 20
) s
inner join pv_metrics m on m.created_at=s.created_at
ORDER BY m.ID DESC ;
created_at verbrauch_ges prev_verbauch_ges
2025-03-23 00:00:04 5628.79 5622.54
2025-03-22 00:00:06 5622.54 5615.44
2025-03-21 00:00:11 5615.44 5609.49
2025-03-20 00:00:13 5609.49 5605.4
2025-03-19 00:00:17 5605.4 5600.45
2025-03-18 00:00:00 5600.45 5591.36
2025-03-17 00:00:03 5591.36 5585.2
2025-03-16 00:00:09 5585.2 5578.96
2025-03-15 00:00:16 5578.96 5571.1
2025-03-14 00:00:04 5571.1 5560.34
2025-03-13 00:00:07 5560.34 5550.54
2025-03-12 00:00:10 5550.54 5540.12
2025-03-11 00:00:13 5540.12 5534.81
2025-03-10 00:00:16 5534.81 5528.48
2025-03-09 00:00:18 5528.48 5521.71
2025-03-08 00:00:17 5521.71 5515.27
2025-03-07 00:00:11 5515.27 5510.17
2025-03-06 00:00:14 5510.17 5504.08
2025-03-05 00:00:06 5504.08 5497.21
2025-03-04 00:00:09 5497.21 null
SELECT created_at, verbrauch_ges
,lag(verbrauch_ges)over(order by created_at) prev_verbauch_ges
FROM (
SELECT min(created_at) as created_at, min(verbrauch_ges) as verbrauch_ges
FROM pv_metrics
group by DATE(created_at)
ORDER BY ID DESC limit 20
)sq
;
created_at verbrauch_ges prev_verbauch_ges
2025-03-04 00:00:09 5497.21 null
2025-03-05 00:00:06 5504.08 5497.21
2025-03-06 00:00:14 5510.17 5504.08
2025-03-07 00:00:11 5515.27 5510.17
2025-03-08 00:00:17 5521.71 5515.27
2025-03-09 00:00:18 5528.48 5521.71
2025-03-10 00:00:16 5534.81 5528.48
2025-03-11 00:00:13 5540.12 5534.81
2025-03-12 00:00:10 5550.54 5540.12
2025-03-13 00:00:07 5560.34 5550.54
2025-03-14 00:00:04 5571.1 5560.34
2025-03-15 00:00:16 5578.96 5571.1
2025-03-16 00:00:09 5585.2 5578.96
2025-03-17 00:00:03 5591.36 5585.2
2025-03-18 00:00:00 5600.45 5591.36
2025-03-19 00:00:17 5605.4 5600.45
2025-03-20 00:00:13 5609.49 5605.4
2025-03-21 00:00:11 5615.44 5609.49
2025-03-22 00:00:06 5622.54 5615.44
2025-03-23 00:00:04 5628.79 5622.54
SELECT created_at, min(verbrauch_ges) verbrauch_ges
,lag(min(verbrauch_ges))over(order by created_at) prev_verbauch_ges
FROM pv_metrics
group by DATE(created_at)
ORDER BY ID DESC limit 20;
created_at verbrauch_ges prev_verbauch_ges
2025-03-23 00:00:04 5628.79 5622.5400390625
2025-03-22 00:00:06 5622.54 5615.43994140625
2025-03-21 00:00:11 5615.44 5609.490234375
2025-03-20 00:00:13 5609.49 5605.39990234375
2025-03-19 00:00:17 5605.4 5600.4501953125
2025-03-18 00:00:00 5600.45 5591.35986328125
2025-03-17 00:00:03 5591.36 5585.2001953125
2025-03-16 00:00:09 5585.2 5578.9599609375
2025-03-15 00:00:16 5578.96 5571.10009765625
2025-03-14 00:00:04 5571.1 5560.33984375
2025-03-13 00:00:07 5560.34 5550.5400390625
2025-03-12 00:00:10 5550.54 5540.1201171875
2025-03-11 00:00:13 5540.12 5534.81005859375
2025-03-10 00:00:16 5534.81 5528.47998046875
2025-03-09 00:00:18 5528.48 5521.7099609375
2025-03-08 00:00:17 5521.71 5515.27001953125
2025-03-07 00:00:11 5515.27 5510.169921875
2025-03-06 00:00:14 5510.17 5504.080078125
2025-03-05 00:00:06 5504.08 5497.2099609375
2025-03-04 00:00:09 5497.21 null
SELECT created_at, min(verbrauch_ges) verbrauch_ges
,lag(min(verbrauch_ges))over(order by date(created_at)) prev_verbauch_ges
FROM pv_metrics
group by DATE(created_at)
ORDER BY ID DESC limit 20;
created_at verbrauch_ges prev_verbauch_ges
2025-03-23 00:00:04 5628.79 5622.5400390625
2025-03-22 00:00:06 5622.54 5615.43994140625
2025-03-21 00:00:11 5615.44 5609.490234375
2025-03-20 00:00:13 5609.49 5605.39990234375
2025-03-19 00:00:17 5605.4 5600.4501953125
2025-03-18 00:00:00 5600.45 5591.35986328125
2025-03-17 00:00:03 5591.36 5585.2001953125
2025-03-16 00:00:09 5585.2 5578.9599609375
2025-03-15 00:00:16 5578.96 5571.10009765625
2025-03-14 00:00:04 5571.1 5560.33984375
2025-03-13 00:00:07 5560.34 5550.5400390625
2025-03-12 00:00:10 5550.54 5540.1201171875
2025-03-11 00:00:13 5540.12 5534.81005859375
2025-03-10 00:00:16 5534.81 5528.47998046875
2025-03-09 00:00:18 5528.48 5521.7099609375
2025-03-08 00:00:17 5521.71 5515.27001953125
2025-03-07 00:00:11 5515.27 5510.169921875
2025-03-06 00:00:14 5510.17 5504.080078125
2025-03-05 00:00:06 5504.08 5497.2099609375
2025-03-04 00:00:09 5497.21 null
SELECT created_at, verbrauch_ges
FROM pv_metrics
group by DATE(created_at)
ORDER BY ID DESC limit 20;
created_at verbrauch_ges
2025-03-23 00:00:04 5628.79
2025-03-22 00:00:06 5622.54
2025-03-21 00:00:11 5615.44
2025-03-20 00:00:13 5609.49
2025-03-19 00:00:17 5605.4
2025-03-18 00:00:00 5600.45
2025-03-17 00:00:03 5591.36
2025-03-16 00:00:09 5585.2
2025-03-15 00:00:16 5578.96
2025-03-14 00:00:04 5571.1
2025-03-13 00:00:07 5560.34
2025-03-12 00:00:10 5550.54
2025-03-11 00:00:13 5540.12
2025-03-10 00:00:16 5534.81
2025-03-09 00:00:18 5528.48
2025-03-08 00:00:17 5521.71
2025-03-07 00:00:11 5515.27
2025-03-06 00:00:14 5510.17
2025-03-05 00:00:06 5504.08
2025-03-04 00:00:09 5497.21