Consumption from Cumulative Readings
Medium
Energy Meter Billing
Each reading is a cumulative meter total. Return each meter, reading date and the kWh used since the previous reading (skip the first reading of each meter). Order by meter, then date.
Table schema
Readings(meter_id INT, reading_date DATE, kwh_total INT)Sample data
Readings
meter_id | reading_date | kwh_total
1 | 2026-01-31 | 1000
1 | 2026-02-28 | 1120
1 | 2026-03-31 | 1180
1 | 2026-04-30 | 1400
2 | 2026-01-31 | 500
2 | 2026-02-28 | 560
2 | 2026-03-31 | 650
Discussion
No discussions yet.
Shalyam Support
Hi! Ask us anything — we'll reply on WhatsApp or Telegram within 24 hours.