I am using Vertica, I have a table with 3 columns: id, error_code and timestamp.
I want to check if in the last hour there were 3 different error_code in 5 minutes window interval for the same id.
this is my query:
select * from
(SELECT id, err_code, timestamp,
COUNT(DISTINCT err_code) OVER (PARTITION BY id ORDER BY timestamp
RANGE BETWEEN INTERVAL '10 minutes'
PRECEDING AND CURRENT ROW) as count
FROM my_table
WHERE timestamp > CURRENT_TIMESTAMP - INTERVAL '1 hour 5 minutes'
group by id, err_code, timestamp
order by id, timestamp) a
order by id, timestamp
However, Vertica doesn't support COUNT(DISTINCT) OVER():
ERROR: Only MIN/MAX and BOOL_AND/BOOL_OR are allowed to use DISTINCT
how to get the wanted result?
without DISTINCT this is the result:

the wanted result should be:

With 4 distinct values altogether for
err_code, add a sum of 4 OLAP expressions returning