skip to Main Content

Iterate through data and calculate the sum of the last three days of each month – Postgresql

DB-Fiddle CREATE TABLE sales ( id SERIAL PRIMARY KEY, event_date DATE, sales_volume INT ); INSERT INTO sales (event_date, sales_volume) VALUES ('2023-01-27', '900'), ('2023-02-28', '500'), ('2023-01-29', '100'), ('2023-01-30', '600'), ('2023-01-31', '450'), ('2023-02-25', '300'), ('2023-02-26', '250'), ('2023-02-27', '845'), ('2023-02-28', '520'), ('2023-03-26', '750'),…

VIEW QUESTION

PostgreSQL: get latest row for each time interval

I have the following table. It is stored as a TimescaleDB hypertable. Data rate is 1 row per second. CREATE TABLE electricity_data ( "time" timestamptz NOT NULL, meter_id integer REFERENCES meters NOT NULL, import_low double precision, import_normal double precision, export_low…

VIEW QUESTION
Back To Top
Search