I’m trying to figure out how to get the minimul of 2 values (or max, or clamp between two values) when doing an SQL query in CrateDB.
I’d like to be able to do a query that is something like this:
SELECT
time,
MIN(AVG(value), 40) AS "Very Low",
MIN(AVG(value), 120) AS "Low",
MIN(AVG(value), 200) AS "Moderate",
MIN(AVG(value), 280) AS "High",
AVG(value) AS "Very High",
FROM
data_table
GROUP BY
time
ORDER BY
time ASC
The above doesn’t work, but I was hoping someone would be able to help me get the same thing another way.