Search code examples
espernesper

How do i get the timestamps for a max(val) and min(val) in a window?


How do i get the timestamps for a MAX(val) and MINval) in a NAMED WINDOW or WINDOW?

Window:

[
t1- 100
t2- 200
t3- 250
t4- 900
]

every time the window is released I want t1 with its min value and t4 with its max value.

I tried with subquery on my NAMED WINDOW, but it says aggregation in subqueries not allowed. Consider using INSERT INTO instead.

Can someone help me out?

Thanks


Solution

  • You can use maxby(val).timestamp