mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-14 18:05:48 +00:00
month param
This commit is contained in:
@ -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
|
Reference in New Issue
Block a user