Trying to use a SQL query in Grafana v8.3.3 to plot a time-series to alert if no orders recieved in a previous hour, but only during essentially business hours (i.e 8am - 10pm).
Since the alert can only be run hourly, I'm going to hack the SQL query to return 1 during non-business hours (i.e 11pm - 7am) so alert will not fire.
Tried using CASE but doesn't seem to see the value returned as being a number - any thoughts on how best to fix this, or implement the above in Grafana?
Thanks in advance!
SELECT $__timeGroup(DATE_CREATED, '1h', 0),
1 AS "BOOKED"
FROM CHANNEL_ORDER
WHERE STATUS = 'BOOKED'
GROUP BY $__timeGroup(DATE_CREATED, '1h', 0)
ORDER BY $__timeGroup(DATE_CREATED, '1h', 0)
SELECT $__timeGroup(DATE_CREATED, '1h', 0),
CASE WHEN TO_CHAR(DATE_CREATED,'HH24') >= 8 AND to_char(DATE_CREATED,'HH24') <= 22) THEN COUNT(1) ELSE 1 END) AS "BOOKED"
FROM CHANNEL_ORDER
WHERE STATUS = 'BOOKED'
GROUP BY $__timeGroup(DATE_CREATED, '1h', 0)
ORDER BY $__timeGroup(DATE_CREATED, '1h', 0)

