Added parameter setup

This commit is contained in:
Dona Maria Absi
2025-04-15 14:40:52 +03:00
parent 30dd8318e3
commit 78cb65d712

View File

@ -1,3 +1,22 @@
CREATE OR REPLACE FUNCTION get_energy_consumption(
input_device_id UUID DEFAULT NULL,
input_start_date DATE DEFAULT NULL,
input_end_date DATE DEFAULT NULL,
input_hour INT DEFAULT NULL,
min_energy_kW INT DEFAULT NULL
)
RETURNS TABLE (
device_id UUID,
date DATE,
hour INT,
energy_consumed_kW INT,
energy_consumed_A INT,
energy_consumed_B INT,
energy_consumed_C INT
) AS $$
BEGIN
RETURN QUERY
WITH total_energy AS (
SELECT
device_id,