month param

This commit is contained in:
Dona Maria Absi
2025-05-09 15:47:05 +03:00
parent 2ba5700fdd
commit 3535c1d8c5

View File

@ -1,12 +1,12 @@
WITH params AS (
SELECT
TO_DATE(NULLIF($2, ''), 'YYYY-MM-DD') AS event_date,
$4::uuid AS space_id
$1::uuid AS space_id,
TO_DATE(NULLIF($2, ''), 'YYYY-MM') AS event_month
)
select psdsd.*
from public."presence-sensor-daily-space-detection" psdsd
JOIN params P ON true
where psdsd.space_uuid = P.space_id
and (P.event_date IS NULL or psdsd.event_date::date = P.event_date)
ORDER BY 1,2
AND (P.event_month IS NULL OR TO_CHAR(psdsd.event_date, 'YYYY-MM') = TO_CHAR(P.event_month, 'YYYY-MM'))
ORDER BY space_uuid, event_date