I have a PL/SQL table with two columns: log_date (DATE) and value (FLOAT). The data is very fine-grained, the difference between log_dates could be a few milliseconds. The value changes over time. I want to find, using SQL, the maximum and minimum amount of time between log_dates it takes for value to increase.
Edit: Example
log_date | value
-------------------
15:00 | 10
15:01 | 10
15:02 | 11
15:03 | 11
15:04 | 11
15:05 | 11
15:06 | 12
Between 15:00 and 15:02 value increased BUT it also increased between 15:03 and 15:06 which took longer, and so I want a query that would return (in this case) ‘3 minutes’ (as a DATE or a NUMBER) – the longest amount of time it took for value to increase.
I can give you an answer in T-SQL, but I’m not sure what dialect you’re using. TBH, a loop here is the first thing that springs to mind (someone else may have a better way of doing it!):
This way, you end up with a table of all differences that you can then query.
HTH